Xcopy bat file problem - batch file loops

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

msmapper

Thread Starter
Joined
Mar 27, 2008
Messages
1
Hi there,

I am trying to write a simple batch file using the xcopy command to copy 250 files to external drive. I need to use xcopy because I need to keep the file file structure in tact.

the batch file text is

xcopy "x:\***\***\file1.txt" "e:\***\***\file1.txt"
xcopy "x:\***\***\file2.txt" "e:\***\***\file2.txt"
xcopy "x:\***\***\file3.txt" "e:\***\***\file3.txt"
xcopy "x:\***\***\file4.txt" "e:\***\***\file4.txt"

when i attempt to run that i just get a loop on the first file that is attempting to copy

if i try to do the xcopy commands one by one (which is taking forever), i get the following message every time

Does File1.txt specify a file name
or directory name on the target
(F = file, D = directory)


the i choose F and the file copies over. I have tried using the /s /e/ /t /v switches but the results are the same?

any ideas on how i can either get the original bat file to work or at least how to supress the message when running the xcopy one at a time.

thanks
Jen
 
Joined
Aug 7, 2007
Messages
9,028
Don't specify a file name for the destination and use the /i switch:
xcopy /c /e /h /i /o /y "X:\<dir>\<subdir>" "E:\<dir>\<subdir>"
This will copy all files in <dir>\<subdir> and any subdirectories including empty ones under <subdir>
It will copy hidden files, and ownership/ACL info -- if the either drive is formated FAT32 you can leave off the /o switch
If you don't need or want to copy every file, this will also work specifying individual file names:
xcopy /c /e /h /i /o /y "X:\<dir>\<subdir>\file1.txt" "E:\<dir>\<subdir>"
xcopy /c /e /h /i /o /y "X:\<dir>\<subdir>\file2.txt" "E:\<dir>\<subdir>"
xcopy /c /e /h /i /o /y "X:\<dir>\<subdir>\file3.txt" "E:\<dir>\<subdir>"


If there are just a few files you don't want to copy, it would be easier to create an exclusion list of files you don't want copied than to name all 250 files and then use the /exclude: switch

HTH

Jerry
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top