Re pengfei:
1.findstr /rc:".*\\*\\*$" means the content of the searched string is: ++++. In the search characters of findstr, when special characters are encountered they need to be escaped with \, for example \ should be written as: \\
2.The function of this code is: if among the subdirectories under the current directory, the last two directory levels consist entirely of numbers, then delete all audio/video files under the lowest-level directory.
3.Obviously, you and I do not understand the OP's intent in the same way (that shameless guy, we argued ourselves red in the face over him, and he went missing on us, hehe).
Your understanding is: the lowest two levels are all numeric, and the parent directories are also all numeric (awkward to say, that is, every level of subdirectory under the current directory is all numeric).
My understanding is: the lowest two levels are all numeric, regardless of the parent directories.
However, no matter what the OP's intent is, it isn't important. But as for what you said, "So it's still better to list all folder names under the current directory and judge whether they are all numeric," I personally don't think it's very necessary:
1.findstr part:
@echo off
set strOldDir=%cd%
set Filter="%cd:\=\\%\\*\\*$"
rem set Filter=".*\\*\\*$"
rem set Filter=".*\\*$"
set FileExtension=*.wmv *.rm *.rmvb *.avi *.mp3 *.wma *.wav
set "cmd1=dir /ad /s /b ^| findstr /rc:"
set "cmd2=cd "%%i" && echo %%i && dir /b"
for /f "delims=" %%i in ('%cmd1%%Filter%') do %cmd2% %FileExtension%
cd %strOldDir%
pause
2.Non-findstr part:
for .... do (
set "strPath=%%i"
set "strPath=!strPath:*%cd%\=!"
call :dosomething "!strPath:\="
)
goto :eof
:dosomething
rem Here, besides the code in 21F for filtering numbers,
rem spaces also need to be filtered
rem parameters should use %~* rather than %~1%~2
goto :eof
Talked strategy on paper for half the night again, I'm off to sleep.