There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 bios boot browser bsod computer cpu crash css dell desktop driver dvd email error excel explorer firefox firefox 3 freeze game graphics hard drive hardware help please hijackthis hjt install internet internet explorer itunes javascript lan laptop malware missing monitor msn network networking openoffice outlook outlook 2003 outlook express php popups problem problems router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless word
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Xcopy bat file problem - batch file loops


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
msmapper's Avatar
Junior Member with 1 posts.
 
Join Date: Mar 2008
27-Mar-2008, 11:30 AM #1
Question Xcopy bat file problem - batch file loops
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
TheOutcaste's Avatar
Computer Specs
Senior Member with 1,537 posts.
 
Join Date: Aug 2007
Location: Oregon, USA
Experience: Intermediate
27-Mar-2008, 12:27 PM #2
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
__________________
Of course I know all the answers ; I just don't always match the answers to the right questions

Warning -- Windows spoken here. (Rated R for Strong Language and Violence -- When your Windows PC flies through a window, that's violent, right?)
giskier's Avatar
Junior Member with 1 posts.
 
Join Date: Jun 2008
Experience: Advanced
01-Jun-2008, 01:17 PM #3
Also, if you are having issues with batch files, you can debug interactively using Running Steps. A full featured batch file debugger which you can check and get from http://www.steppingsoftware.com .
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:11 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.