Batch file to move multiple files to multiple dir

Ask a question


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.

Windows - Exception Processing Message
Batch File - Rename TXT file if file exists