how to move folders with a loop over folders (in batch)?

后端 未结 1 499
慢半拍i
慢半拍i 2021-01-13 20:31

Situation:

I try to move files inside a loop in shell but my code is not working.

for /D %%F in (*) do (
   if \"%%F\" NEQ \"%direct         


        
相关标签:
1条回答
  • 2021-01-13 20:50

    Try below code to move files from one folder to another in batch script:

    for /f %%a in ('dir /a:-D /b') do move /Y "%%~fa" "%directoryToPutFilesIn%"
    

    Explanation :

    dir /a:-D /b : This command will list all files in the directory 
    move /Y "%%~fa" "%directoryToPutFilesIn%" : This will move all files in the directory where this command is executed to the destination you have mentioned.
    %%~fa : This command will get full qualified path of the file with it's name.
    

    Try Below code Move directories : Below command will move directories in the Path where this command is executed to the destination provided. In this that will be H:\ Drive, Change it accordingly

    for /D %%b in (*) do move /Y "%%~fb" "H:\"
    
    0 讨论(0)
提交回复
热议问题