recursive move command on windows

前端 未结 6 1550
暖寄归人
暖寄归人 2021-02-14 15:25

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/ --remov         


        
相关标签:
6条回答
  • 2021-02-14 15:45

    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
    
    0 讨论(0)
  • 2021-02-14 15:53

    I know this is an old thread, but since it does not have a correct answer I figured I'd tie it off.

    The old DOS command to accomplish this is:

       move <source directory> <destination directory>
    

    So in the OP question:

       move C:\sourceFolder c:\destinationFolder
    

    The folder and everything in the folder (including sub-directories) will be moved.

    0 讨论(0)
  • XCOPY should do the trick, I use it it in batch files all the time

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

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

    Let me know if you have more questions

    0 讨论(0)
  • 2021-02-14 16:06
    @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 讨论(0)
  • 2021-02-14 16:07

    Robocopy did wonders for me:

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

    I used it to move all files with certain mask out of c:\cache and its numerous subdirectories.

    0 讨论(0)
  • 2021-02-14 16:08

    For recursive move in windows, a simple move command is ok. Here is the example, I think it would be helpful.

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

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

    0 讨论(0)
提交回复
热议问题