1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Xcopy bat file problem - batch file loops

Discussion in 'DOS/Other' started by msmapper, Mar 27, 2008.

Thread Status:
Not open for further replies.
  1. msmapper

    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
     
  2. TheOutcaste

    TheOutcaste

    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
     
  3. giskier

    giskier

    Joined:
    Jun 1, 2008
    Messages:
    1
    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 .
     
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 733,556 other people just like you!

Loading...
Similar Threads - Xcopy file problem
  1. niedernsill
    Replies:
    3
    Views:
    380
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/697625

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice