@echo off
setlocal
set "targetFolder=C:\Path\To\Target\Folder"
set "cutoffDate=%date% -30"
for /d %%D in ("%targetFolder%\*") do (
pushd "%%D"
for /f "delims=" %%F in ('dir /b /a-d /s ^| findstr /b /c:"%targetFolder%" ^| findstr /v /i /c:"Thumbs.db"') do (
for /f "tokens=1-3 delims=/" %%A in ("%%~tF") do (
set "fileDate=%%C-%%A-%%B"
if "%fileDate%" LSS "%cutoffDate%" (
echo Deleting "%%F"
del "%%F" /q
)
)
)
popd
rd "%%D" 2>nul
)
想用bat想写一个能够自己清理30天以上文件夹及文件的代码但是不成功,求大神指导。
最新推荐文章于 2024-03-22 12:57:33 发布