简体   繁体   中英

Windows script batch to copy files from different folders to other folders

The easiest way to explain the problem is by an example.

I want to do something like this:

file x in /path_1/A/x copy in /path_2/A/
file x in /path_1/B/x copy in /path_2/B/
...
...
file x in /path_1/Z/x copy in /path_2/Z/

From command line with a script in Windows.

@echo off

cd /path_1
for /D %%d in (*) do (
   if exist "%%d/x" (
      if not exist "/path_2/%%d" md "/path_2/%%d"
      copy "%%d/x" "/path_2/%%d"
   )
)

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