Recursive copy files from folders Part 2
Posted: 30 Aug 2014 02:21
Hi guys, a little bit modification of grab2.bat
./cats/cata/file.bmp
./cats/catb/file.bmp
./cats/catb/file.png
./cats/catb/file.gif
./cats/grab.bat
This time I want grab2.bat to do this loop over the current folders and get all the .png and .gif files from catb folder, copy them and put them in cata folder, E.g (file.bmp, file.png, file.gif) overwrite same file
thank you
Code: Select all
@Echo Off & SetLocal EnableExtensions DisableDelayedExpansion
Set _ext=.pdf
PushD %~dp0
For /D %%a In (*) Do If Exist "%%a\*%_ext%" Call :Sub "%%a"
Exit/B
:Sub
Set _cnt=0
For %%a In ("%~1\*%_ext%") Do Set/A _cnt+=1
If %_cnt% NEq 1 GoTo :EOF
If Not Exist "%~1%_ext%" Echo(F|XCopy "%~1\*%_ext%" "%~dp0%~1%_ext%">Nul
./cats/cata/file.bmp
./cats/catb/file.bmp
./cats/catb/file.png
./cats/catb/file.gif
./cats/grab.bat
This time I want grab2.bat to do this loop over the current folders and get all the .png and .gif files from catb folder, copy them and put them in cata folder, E.g (file.bmp, file.png, file.gif) overwrite same file
thank you