while reading your question i had an idea, why not using something like lists in python instead of using a file that contain all your extension that you want to delete.
Try this:
Code: Select all
@echo off
::VARIABLES::
set sd=%systemdrive%
set del=del /q/f
set cmd=cmd /c
set "list=bmp,cab,dll,exe,ini,log,msi,txt"
set "list_len=8"
setlocal enabledelayedexpansion
For /L %%@ in (1,1,%list_len%) Do (
For /F "tokens=1-%list_len% delims=," %%a in ("%list%") Do (
Call :del_type "%%a"
Call :del_type "%%b"
Call :del_type "%%c"
Call :del_type "%%d"
Call :del_type "%%e"
Call :del_type "%%f"
Call :del_type "%%g"
Call :del_type "%%h"
)
)
Pause
Exit /B
:del_type
For /F "delims=" %%a in ('dir/b "%sd%\*.%~1"') do (
%cmd% %del% "%sd%\%%a">nul 2>&1
)
goto :eof
Edited:This is the new version of the code above
Code: Select all
@echo off
::VARIABLES::
set sd=%systemdrive%
set del=del /q/f
set cmd=cmd /c
:: Max list elements & lenght is 9
set "list=txt,py,jpg,exe"
set "list_len=4"
setlocal enabledelayedexpansion
For /F "tokens=1-%list_len% delims=," %%a in ("%list%") Do (
Call :command "%%a" "%%b" "%%c" "%%d"
)
)
Pause
Exit /B
:command
Pushd %sd%
For /F "delims=" %%a in ('Dir /B /A:-D "*.%~1" "*.%~2" "*.%~3" "*.%~4" "*.%~5" "*.%~6" "*.%~7" "*.%~8" "*.%~9"') Do (
%cmd% %del% "%%a">nul 2>&1
)
Popd
goto :eof
The command function can be changed depending on the commands that is required.