Jump to content

Creating a simple folder-to-folder refresher

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
6 replies to this topic

#1
oege

oege

    Newbie

  • Members
  • Pip
  • 4 posts
Hi there, and good morning to all!

This post might end up becoming a wee bit long, but I'll try to keep it short:

Here at work (a Ford\Nissan Dealership\workshop in Norway, for those whos intrested), we have severel programs for managing all the parts for Nissan and Ford. Ford's program are easy to handle, but the updating-part of the Nissan Program is a little bit tricky. It's not hard, but time-consuming because of the fact that 1) I have to do it by hand, and 2) I'm the only one here who can do it (all the others have computer-insight like ball-pens).

The Nissan-program works like this:
The program itself are kept in a folder stored locally on the computer. However, the files which is containing all the files, are kept on a diffrent computer, which all our computers in the part-shop are connected to. However, due to performance-issues, I had to store all the parts-files locally on each computer. This solves some problems, but open up for others.

So here is the ten dollar question; is it hard to create a little script, or progam, or whatever, that simply copies the files in the main directory, and replaces the old ones with the new ones in the locally stored folder?
Yes, I know it's not hard, and Yes, I know I sound a bit lazy, but it does require some time to do, and there is'nt always a 24-hour day offers enough time do do it.

If I explained this in a hard way, I'l try to write it here:
A:\xxx\NISSAN PARTS\ <- Contains files, which becomes old.
B:\ <- Contains files, which becomes updated.
Program replaces files in folder on drive A with copied files from driv B.

But, and this is perhaps the biggest problem of them all, I think, I never coded anything! Sure, I did som easyer-than-basic HTML'ing back in the days, but I never actually make something that is worth praise...

So, is this so hard to do that I have to offer my soul to the Devil himself to make, or can I actually have a chance? :)

EDIT:
Perhaps something like this? :)

v1.0
START
- on program execute:
- open root [ R:\ ]
- copy all files, folders, sub-folders and sub-files
- close root [ R:\]
- open root [ C:\NISSAN\DELEFILM EURO\ ]
- Paste all files
- Overwrite on all files accepted
- Overpaste finished
- Close Program
/END

v2.0
START
- on program execute
- Enable custom root adress for sender
- copy all files, folders, sub-folders and sub-files from custom root adress
- Enable custom root adress for reciever
- Paste all files, and enable overwrite, on reciver custom root adress
- On begun copy, open %tab
- On ended copy, close %tab
- On ended copy, show message "complete"
- On closed message, end program
/END

Edited by oege, 16 July 2009 - 03:19 AM.


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You could create a simple batch file to do this. You may want to think about getting a general inventory program with a central database, though. Having two different inventory programs sounds like a pain.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
oege

oege

    Newbie

  • Members
  • Pip
  • 4 posts
Thanks for the answer :)
I looked a little on the web, and I tried to make a batch-code, like this

echo off 
cls 
:menu
echo.
echo.................................
echo PRESS DESIRED OPERATION
echo.................................
echo.
echo 1 - COPY nissan FAST from Network Core
echo 2 - exit
echo.
set /p m=Type 1 or 2, Then Press Enter
if %M% ==1 GOTO UPDATE
if %M% ==2 GOTO EOF
:UPDATE
xcopy /h /r /k /y /S /E C:\DELEFILM\
GOTO MENU

I sincerly doubt that this is correct, but what needs fixing? All I want it to do is copy the files from Directory A, and paste over the old ones in directory B.

EDIT AGAIN: Looking back on this code, I realized I forgot to put in the directory which contains all the files which it is supposed to copy in the first place! *embarraced*
It is simply all the files in a direcotry called R:\ (or N:\ , I forgot, can change it when I arrived at work tomorrow)... Where shall I put that?

Edited by Jaan, 17 July 2009 - 03:30 AM.
Please use code tags when you are posting your codes!


#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Since you're using absolute directories, you should be able to store/run it from most anywhere.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
oege

oege

    Newbie

  • Members
  • Pip
  • 4 posts

WingedPanther said:

You could create a simple batch file to do this. You may want to think about getting a general inventory program with a central database, though. Having two different inventory programs sounds like a pain.
Yeah, I know that would be more suiting, however, Nissan and Ford delivers each a special program to read the seperate film's for the part, so we'r stuch with 3 programs actually; 1 for Nissan Parts, 2 for Ford parts and 3 for General inventory administrive. It's a Drag :(

However; after reading a bit more, I came to the conclusion to alter my code a wee bit:
from
xcopy /h /r /k /y /S /E C:\DELEFILM\
to
xcopy N:\ C:\NISSAN DELEFILM\ /E /i /y

asmuing I read the guide correctly:
Syntax
XCOPY source [destination] [options]
/E Copy folders and subfolders, including Empty folders.
/I If in doubt always assume the destination is a folder e.g. when the destination does not exist.

Edited by oege, 16 July 2009 - 01:29 PM.


#6
oege

oege

    Newbie

  • Members
  • Pip
  • 4 posts
Problem solved! :D I finally created my first batch wich actually worked! To some that might not be a big deal, but since I only started this last night, and NEVER touch batch or coding before, I'm quite impressed with myself ^^

The code ended up like this:
echo off
cls
:menu
echo.
echo................................................
echo PLEASE INSERT CORRECT OPERATION
echo.................................................
echo.
echo 1 - UPDATE
echo 2 - EXIT
echo.
set /p m=Type 1 or 2 to contiune
if %M% ==1 goto UPDATE
if %M% ==2 goto EOF
:update
xcopy R:\ "C:\NISSAN DELEFILM" /E
goto menu

A little annoying that I have to confirm that it shall overwrite the existing files, but perhaps I can find a solution for that soon :)

And many thanks to WingedPanther, who took the trouble of answering :D

EDIT: a little /Y solved that problem too :D

Edited by Jaan, 17 July 2009 - 03:29 AM.
Please use code tags when you are posting your codes!


#7
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'm glad I could help :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog