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

后端 未结 7 2639
故里飘歌
故里飘歌 2021-02-19 18:03

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 direc

7条回答
  •  误落风尘
    2021-02-19 18:35

    Using robocopy included with Windows 7, I found the /XD option did not prevent the source folder from also being moved.

    Solution:

    SET MoveDirSource=\\Server\Folder
    SET MoveDirDestination=Z:\Folder
    FOR /D %%i IN ("%MoveDirSource%\*") DO ROBOCOPY /MOVE /E "%%i" "%MoveDirDestination%\%%~nxi"
    

    This loops through the top level folders and runs robocopy for each.

提交回复
热议问题