Batch file to move multiple files to multiple dir

January 2017



Issue


I would like a batch file to move multiple files from multiple directories to one directory on one
drive. Example:


C:CanProdAMDDetailProc*.* 
C:CanProdAMDSumProc*.* 
C:CanProdPMDDetailProc*.* 
C:CanProdPMDSumProc*.* 
C:CanProdSMDDetaiilProc*.* 
C:CanProdSMDSumProc*.* 
C:CanProdKMDDetailProc*.* 
C:CanProdKMDSumProc*.*

Solution


You can try with the below script,

@echo off 

for /f "Tokens=* delims= " %%g in ('dir /b /s "C:CanProd" ^| find "Proc\"') do move"%%g" "destination path"


Note:

The destination path should finish like " D:test\". Path should end with the slash ().

Note


Thanks to Hawk for this tip on the forum.

Related


Published by aakai1056. Latest update on January 27, 2010 at 06:28 AM by aakai1056.
This document, titled "Batch file to move multiple files to multiple dir," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).