简体   繁体   中英

Batch copying to all folders

I need to batch copy two folders, let's call them A and B, from F:\\Sourcefolder\\ to F:\\destinationfolder subfolders (not to destination folder itself).

Now I know when batch copying file ( file.exe for example) it is supposed to look something like this

for /r "F:\destinationfolder" %%i in (.) do @copy "F:\Sourcefolder\file.exe" "%i"

In each of those subfolders there is a lot of files. After copying A and B folders to all subfolders, I would like to move all files within the subfolders to folder A within their folder. Is this possible to do?

the XCOPY command is designed for folder copy, FOR /D will list level1 folders:

for /d %%a in ("F:\destinationfolder\*") do (
    XCOPY "F:\Sourcefolder\A\*" "%%~fa" /s /i
    XCOPY "F:\Sourcefolder\B\*" "%%~fa" /s /i
)

for recursive copy (all subfolders):

for /r /d "F:\destinationfolder\" %%a in (*) do (
    XCOPY "F:\Sourcefolder\A\*" "%%~fa" /s /i
    XCOPY "F:\Sourcefolder\B\*" "%%~fa" /s /i
)

FOR /R will not work properly if there's no wildcard in the brackets - ? or *

ROBOCOPY , XCOPY

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM