Reputation: 734
This batch code is to search all the PDF files in the path specified by the user and copy them all in the home folder and then deleting everything that is inside that folder (subfolders and files). How can I force my code to look for multiple files like pdf,txt and else.
@echo off
setlocal enabledelayedexpansion
goto :main
:main
setlocal
cls
echo.
echo Enter the home directory path where you want to apply the cleaning
set /p path=
echo %path%
cd %path%
for /d %%g in (*) do (
echo %%g
cd %%g
for /r %%p in (*.pdf) do (
set dest=!cd!
set app=/
copy %%p !%dest%%app%!
echo %%p
echo !cd!
)
for /d %%z in (*) do (
rmdir %%z /s /q
)
cd ..
)
pause
endlocal
goto :eof
Upvotes: 0
Views: 46
Reputation: 21965
Nothing prevents you from doing
for /r %%p in ( *.jpg *.png ) do (
REM do something with %%p
)
The catch is that you can use any number of extensions separated by space withing parenthesis.
Upvotes: 2