How can I move all the files from one folder to another using the command line?

前端 未结 9 1281
北恋
北恋 2020-12-01 02:53

What is the best command to move all files from one folder to another?

I want to do this from within a batch file.

9条回答
  •  庸人自扰
    2020-12-01 03:25

    move c:\sourcefolder c:\targetfolder
    

    will work, but you will end up with a structure like this:

    c:\targetfolder\sourcefolder\[all the subfolders & files]
    

    If you want to move just the contents of one folder to another, then this should do it:

    SET src_folder=c:\srcfold
    SET tar_folder=c:\tarfold
    
    for /f %%a IN ('dir "%src_folder%" /b') do move "%src_folder%\%%a" "%tar_folder%\"
    
    pause
    

提交回复
热议问题