Search code examples
windowscommand-line

recursive move command on windows


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

mv ...

or

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

but Windows "move" can't do the same

maybe there is a windows simple alternative, simpler and more performant than

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

Linux mv seems to update directories pointer, but the above Windows command will do hard stuff? I guess it's not a good idea for the big folders I need to frequently move


Solution

  • 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