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.

Solved: Xcopy batch how to move same files in multi folders into 1 folder

Discussion in 'DOS/Other' started by Reconsniper1, Apr 19, 2008.

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

    Reconsniper1 Thread Starter

    Joined:
    Apr 16, 2008
    Messages:
    15
    Okay...new question. I have looked at the flags for Xcopy and experimented around. My problem is i'm trying to copy all the .doc files in the directory and subdirectories (ex: c:\test\testa\testb etc) underneath it, have it put those documents in a c:\test1 but without the file structure. I do not want the subdirectories, but just the files.

    I've tried xcopy /s c:\test\*.doc c:\test1

    It will give me the files but it will have them in the same file structure.

    You guys are awesome and thanks for your help!
     
  2. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Here ya go

    Code:
    @echo off
    setlocal
    pushd "c:\test"
    for /f "tokens=*" %%a in ('dir /b /a-d /s *.doc') do copy "%%a" "c:\test1"
    popd
    
     
  3. Reconsniper1

    Reconsniper1 Thread Starter

    Joined:
    Apr 16, 2008
    Messages:
    15
    Works awesome! I have to google the use of Tokens and stuff b/c that seems to be used in a lot of the more complex batches. Thanks again!
     
  4. devil_himself

    devil_himself

    Joined:
    Apr 7, 2007
    Messages:
    4,910
    Delims: used to break the line up into chunks that you can reference with variables %%i %%j %%k ...
    Tokens: used so you can tell the FOR command how many chunks you want to break it up into and how many will be handled by variables

    For More Info Open Command Prompt And Type - For /?
     
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!

Thread Status:
Not open for further replies.

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

  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