Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows batch command to move all folders in a directory with exceptions

I am trying to write a Windows Batch file that will allow me to move all directories within a given source directory into a target directory that exists within that source directory.

Obviously my move command with need to only apply to directories and also exclude the target directory from being processed.

Is this possible with a Windows batch command?

like image 227
William Owen Avatar asked Sep 18 '11 12:09

William Owen


1 Answers

On windows batch:

FOR /d %%i IN (MySourceDirectory\*) DO move "%%i" MyTargetDirectory\%%~ni

The above command moves all directories found in MySourceDirectory (/d) to MyTargetDirectory using the original directory name (~ni) Robocopy's move first does a copy, then delete, so it is slower.

like image 89
River Rock Avatar answered Oct 13 '22 22:10

River Rock