search
top

Using xxcopy to copy files from subdirectories to one directory and combine

Ever wanted to copy files in sub-directories into a single directory? Well there’s a handy utility for Windows systems called xxcopy that does this and more.

What is XXCOPY ?

  • A versatile file management tool for Microsoft Windows®.
  • It is a command-line program (without graphical user interface).
  • Supports all Windows versions (except Windows CE).
  • It has more command switches (>230) than any other tool of its kind.
  • An ideal component for batch files for simple and complex scripting.
  • Accesses remote (networked) computer storage and local external USB drives.
  • Command syntax compatible with Microsoft’s XCOPY with few exceptions.
  • Competes with (supersedes) Microsoft’s RoboCopy.
  • One download package contains both the 32-bit and 64-bit XXCOPY versions.
  • Extremely rich in file-selection mechanism (by filedate, size, attrib, etc.).
  • Wild-Wildcard (specify a path with wildcard anywhere for any number of times).
  • Functions for Copy, List, Gather, Delete, Move, Flatten-Dir, and more …

For this post I wanted to show a quick way to gather files from sub-directories with a single command.

To install xxcopy, download from http://www.xxcopy.com/xcpymain.htm. The latest version is 3.11.2. Unzip and double-click on install.bat. By default it will install to c:\windows\system32 and put 2 shortcuts on your desktop.

The main objective was to copy all the text files from the C:\FileCol directory on myserver and combine the contents of those files into a single file. This is done by using xxcopy and copy commands.

First lets use xxcopy to get the files to a single location. In this case I have files in sub-directories to retrieve, xxcopy has the /sg switch which gathers files into one-level directory and Copies directories and sub-directories except empty ones.

So the syntax is:
xxcopy /sg location_of_files destination

Example:
xxcopy /sg \\myserver\c$\FileCol\*.txt c:\temp\admin

Now that we have our files wecan use the copy command to combine all the contents into one file.

cd c:\temp\admin
copy *.txt Administrators.txt

All done. You can do much more with xxcopy. Feel free to explore the long list of command parameters http://www.xxcopy.com/xxcopy01.htm and the cookbook here http://www.xxcopy.com/xxcopy11.htm

Leave a Reply

Your email address will not be published. Required fields are marked *

top