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.

Batch file to copy subfolders?

Discussion in 'Windows XP' started by halcour, Jul 7, 2005.

Thread Status:
Not open for further replies.
Advertisement
  1. halcour

    halcour Thread Starter

    Joined:
    Mar 2, 2005
    Messages:
    496
    Is there a simple way to copy an entire folder and its subfolders to another location using a batch file?

    Thanks,
    Harold
     
  2. DoubleHelix

    DoubleHelix Banned

    Joined:
    Dec 9, 2004
    Messages:
    24,388
    Use XCOPY. At a command prompt, type: xcopy /? to see how to use it.
     
  3. halcour

    halcour Thread Starter

    Joined:
    Mar 2, 2005
    Messages:
    496
    Boy that was fast! Thanks DH!

    Harold
     
  4. DaveBurnett

    DaveBurnett Dave Trusted Advisor

    Joined:
    Nov 11, 2002
    Messages:
    11,647
    Yes, the command you want is XCOPY
    Open a Command prompt and type XCOPY /? to see the format of the command.
    You can then create a text file with a .BAT extension containing the command and run it whenever you like.
     
  5. Bob Cerelli

    Bob Cerelli

    Joined:
    Nov 2, 2002
    Messages:
    22,468
    To answer the question, with XCOPY use the /S switch to copy subdirectories.

    For example:

    XCOPY C:\DATA G:\DATA /S

    Would copy all the files in C:\DATA and the subdirectories to G:\DATA
     
  6. JohnWill

    JohnWill Retired Moderator

    Joined:
    Oct 19, 2002
    Messages:
    106,409
    Gee Bob, I think he figured it out with the Help already.

    Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
     
  7. Bob Cerelli

    Bob Cerelli

    Joined:
    Nov 2, 2002
    Messages:
    22,468
    Didn't want to make any assumptions so decided just to give the specifics as well as an example. Hope that was ok.

    Another switch I like to use is /D

    This is handy when doing things like backing up just data files to another hard drive. This switch will only backup new or changed files. So after the first time a backup is made, it generally goes a lot faster than copying everything all over again.
     
  8. Sponsor

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...
Thread Status:
Not open for further replies.

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