Link to home
Start Free TrialLog in
Avatar of bsjld
bsjld

asked on

USING XCOPY COMMAND TO COPY 1 SINGLE FILE WITH .TXT TO CREATE A BATCH FILE

hI ALL,
i HAVE CREATED A BATCH FILE TO COPY ALL FILES, DIRECTORIES AND SUB DIRECTORIES AND THIS WORKED FINE.  nOW i WANT TO SETUP THE SAME TYPE FILE TO WORK WITH COPING 1 SINGLE FILE OVER BUT CAN'T GET IT TO WORK.  HERE IS WHAT I DID:

XCOPY C:\HOME\housing.mdf*.* Y:\TAAG-TIME-BU\TAAG\

THE THING IS ONCE I SAVE THE .TXT AS A BAT FILE AND DOUBLE CLICK IT, IT COMES UP AND GES AWAY QUICKLY NOT COPYING ANYTHING OVER.  i KNOW I'M DOING SOMETHING WRONG.
ASKER CERTIFIED SOLUTION
Avatar of mds-cos
mds-cos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the other thing you can do to see what is actually occuring is to
goto   start
up to run
type in cmd  
press ok
and run your batch file from within the cmd console  that should show you what its doing and wehre its failing as the commands will stay in the window and the window won't poof on you.

--Wild
Avatar of Steve Knight
(without the " around it there).

If you have adjusted the paths you may need to put "" around the paths though.

XCOPY "C:\HOME\housing.mdf" "Y:\TAAG-TIME-BU\TAAG"

I suggest you run it from the cmd.exe prompt once to see that it works for you.  It could be a matter of permissions, or if the file already exists for instance then you may need to add options to the xcopy line.

e.g.

xcopy /d/y "c:\home\housing.mdf" "y:\taag-time-bu\taag"

would copy the file if it is newer and overwrite without prompting.

Steve
In you BAT file include PAUSE as the last line.
You may wish to include the /i parameter which advises that the destination is a directory

xcopy /i/y "c:\home\housing.mdf" "y:\taag-time-bu\taag"

Cheers, Andrew