Batch file to move multiple files to multiple dir

December 2016



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 :

This document entitled « Batch file to move multiple files to multiple dir » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.