Thursday, February 25, 2016

Copying files Quickly from Multiple sub-directories into one directory using BATCH file

Create a BATCH file (copyFiles.bat) with following one line content:

for /R Data\ %%f in (*.xml) do copy %%f AllData\

In this batch file, Data is directory where there are multiple sub-directories (A, B and C). In those, sub-directories, there are XML files.

Data
|
--A
  |
  --1.xml
  --2.xml  
  --3.xml
--B
  --4.xml
  --5.xml  
  --6.xml
--C
  --7.xml
  --8.xml  
  --9.xml
 
We want to copy all these XML files in one directory named AllData. Instead of going in each directory and copying files manually, we can achieve this using above batch file. This would be really helpful if there are thousands of files to move.

After executing copyFiles.bat, you will see all the XML files in AllData Directory.

No comments:

Post a Comment