::-----------------------------------------@echo off
setlocal EnableDelayedExpansion
set _targetDir=C:\Users\ShiningWang\test
set _thisFilePath=%0
:loop
for /r %_targetDir% %%i in (*.*) do (
REM 檔案全路徑
set _filePath=%%i
if not "!_filePath!"==%_thisFilePath% (
REM 擷取檔案字尾
set suffix=!_filePath:~-4!
if not "!suffix!"==".txt" (
del /q "%%i"
)
pause::----------------------------------------------------------
::-----------------------------------------@echo off
setlocal EnableDelayedExpansion
set _targetDir=C:\Users\ShiningWang\test
set _thisFilePath=%0
:loop
for /r %_targetDir% %%i in (*.*) do (
REM 檔案全路徑
set _filePath=%%i
if not "!_filePath!"==%_thisFilePath% (
REM 擷取檔案字尾
set suffix=!_filePath:~-4!
if not "!suffix!"==".txt" (
del /q "%%i"
)
)
)
pause::----------------------------------------------------------