Modify batch to work on all subdirectories down to the end

March 16, 2019 at 23:39:10
Specs: Windows 10
I found the following dos batch at this link: https://stackoverflow.com/questions... which overwrites files in the destination directory A with files from the source directory B once those file names are matched. This batch works only on one level directory.

Could this batch be modified to work on all subdirectories down to the end of the tree? Here it is:

for /r "C:\folderA" %%a in (*.filetype) do if exist "C:\folderB\%%~nxa" copy /y "C:\folderB\%%~nxa" "C:\folderA\%%~nxa"

Appreciating any precious assistance with this question ..

Many thanks in advance.


See More: Modify batch to work on all subdirectories down to the end

Reply ↓  Report •

#1
March 26, 2019 at 13:54:31
pretty sure you can, but first explain this a bit further:
"Could this batch be modified to work on all subdirectories down to the end of the tree?"

a visual example of the file structure would be nice.

if you're talking about folders within folders, within folders i might not do it, since i tend to make mistakes when there for loops calling other for loops from within a loop.

but given i'm bored enough I probably still do an attempt :D

i5-6600K[delid]@4.8GHz/4.4GHz cache/@1.440v | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | Sapphire Nitro+ SE RX 590 8GB@1525Mhz core@1.0v/2260MHz@1500MHz timings BiosModded


Reply ↓  Report •

#2
March 26, 2019 at 15:42:55
Robocopy is your friend. Why does everyone ignore it?
ROBOCOPY c:\folderA c:\folderB *.filetype /XL /E

How To Ask Questions The Smart Way


Reply ↓  Report •

#3
March 27, 2019 at 01:40:03
because we never use Xcopy and robocopy, for example, I have only used it once or twice in my life.

i5-6600K[delid]@4.8GHz/4.4GHz cache/@1.440v | 2x4GB Crucial-DDR4-2400CL17@14-15-15-28 1T 3000MHz@1.4v | Sapphire Nitro+ SE RX 590 8GB@1525Mhz core@1.0v/2260MHz@1500MHz timings BiosModded


Reply ↓  Report •
Related Solutions


Ask Question