Batch file to copy directories recursively

前端 未结 4 1710
情书的邮戳
情书的邮戳 2020-12-01 00:40

Is there a way to copy directories recursively inside a .bat file? If so, an example would be great. thanks.

4条回答
  •  执念已碎
    2020-12-01 00:54

    You may write a recursive algorithm in Batch that gives you exact control of what you do in every nested subdirectory:

    @echo off
    call :treeProcess
    goto :eof
    
    :treeProcess
    rem Do whatever you want here over the files of this subdir, for example:
    copy *.* C:\dest\dir
    for /D %%d in (*) do (
        cd %%d
        call :treeProcess
        cd ..
    )
    exit /b
    

    Windows Batch File Looping Through Directories to Process Files?

提交回复
热议问题