Window recursive command

I need to make a .bat copy of .sh, I don't know a lot of Windows cmd. On Linux, I could do

mv ... 

or

 rsync -a SOURCE/ DEST/ --remove-sent-files --ignore-existing --whole-file 

but Windows "move" cannot do the same

there may be a simple alternative to Windows, simpler and more efficient than

 for /R c:\sourceFolder\ %%G in (*) do ( move /Y "%%G" c:\destinationFolder\ ) 

Linux mv seems to be updating directory pointers, but will the aforementioned Windows command do the heavy stuff? I think this is not a good idea for large folders that I need to move frequently

+8
source share
6 answers

The move command can move directories as well as files.

 cd /d C:\sourceFolder rem move the files for %%i in (*) do move "%%i" C:\destinationFolder rem move the directories for /d %%i in (*) do move "%%i" C:\destinationFolder 
+7
source

Robocopy did wonders for me:

  robocopy c:\cache c:\cache-2012 ?????-2012*.hash /S /MOV 

I used it to move all files with a specific mask from c:\cache and its many subdirectories.

+13
source

XCOPY should do the trick, I use it in batch files all the time

something like if you're just trying to configure .sh files

 XCOPY /E /H /Y /C "%SOURCEDIR%\*.sh" "%TARGETDIR%" 

Let me know if you have more questions.

0
source
 @echo off setlocal set DIR= set OUTPUTDIR=C:\Documents and Settings\<username>\Desktop\sandbox1\output for /R %DIR% %%a in (*.jpg) do xcopy "%%a" "%OUTPUTDIR%" 
0
source

I know this is an old branch, but since it does not have the correct answer, I decided to link it.

Old DOS command for this:

  move <source directory> <destination directory> 

So, in the OP question:

  move C:\sourceFolder c:\destinationFolder 

The folder and everything in the folder (including subdirectories) will be moved.

0
source

For recursive movement in windows, a simple move command is fine. Here is an example, I think it would be useful.

 move D:\Dbbackup\*.dmp* D:\Dbbackup\year\month\ 

Where .dmp is the file extension that will be moved to the folder of the recursive folder Dbbackup, then year, then month.

-one
source

All Articles