批处理文件未删除

编程入门 行业动态 更新时间:2024-10-26 13:32:26
本文介绍了批处理文件未删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

此批处理文件未删除.我得到的错误是找不到路径.我想删除C驱动器上不到一分钟的任何* .zip,*.txt文件.

This batch file isn''t deleting. The error I am getting is path not found. I want to delete any *.zip, *.txt files anywhere on my c drive that are less than a minute old.

@echo off setlocal call :DateToMinutes %date:~-4% %date:~-10,2% %date:~-7,2% %time:~0,2% %time:~3,2% NowMins for /f "delims=" %%a in ('dir * /a-d /b') do call :CheckMins "%%a" "%%~ta" goto :EOF :CheckMins set File=%1 set TimeStamp=%2 call :DateToMinutes %timestamp:~7,4% %timestamp:~1,2% %timestamp:~4,2% %timestamp:~12,2% %timestamp:~15,2%%timestamp:~18,1% FileMins set /a MinsOld=%NowMins%-%FileMins% if %MinsOld% leq 1 del %*.zip,*.txt% goto :EOF :DateToMinutes setlocal set yy=%1&set mm=%2&set dd=%3&set hh=%4&set nn=%5 if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%) set /a dd=100%dd%%%100,mm=100%mm%%%100 set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2 set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633 if 1%hh% LSS 20 set hh=0%hh% if /i {%nn:~2,1%} EQU {p} if "%hh%" NEQ "12" set hh=1%hh%&set/a hh-=88 if /i {%nn:~2,1%} EQU {a} if "%hh%" EQU "12" set hh=00 if /i {%nn:~2,1%} GEQ {a} set nn=%nn:~0,2% set /a hh=100%hh%%%100,nn=100%nn%%%100,j=j*1440+hh*60+nn endlocal&set %6=%j%&goto :EOF

另外,我认为我需要修改日期而不是创建日期. 试过这个...没有工作. 如果%MinsOld%leq 1 del%"c:\ *.zip"%

Also I think I need to do the modified date as opposed to the date created. Tried this...No Work. if %MinsOld% leq 1 del %"c:\*.zip"%

推荐答案

可能是脚本有点复杂吗?也许您可以更简单地解决问题.看看下面的链接,了解我的意思. scottelkin/programming/delete-files-older-than -date-using-batch-files/ [ ^ ] wwwputerhope/backup.htm [ ^ ] 祝你好运! Could it be you''re script is somewhat complicated? Maybe you could resolve the problem more simple. Have a look at the links below to see what I mean. scottelkin/programming/delete-files-older-than-date-using-batch-files/[^] wwwputerhope/backup.htm[^] Good luck!

这很不错,!!!!!!!!!!! This works, Sublimely!!!!!!!!!! @echo off setlocal for /f "delims=" %%b in ("%time%") do set "tm=%%b" set "tm=%tm:~0,5%" set "tm=%tm: =0%" for /f "tokens=2" %%b in ("%date%") do set "d8=%%b" set filespec=\*.zip \*.txt \*.jpg for /f "delims=" %%a in (' dir %filespec% /a:-d /o:n /b /s') do ( if "%%~ta"=="%d8% %tm%" ( del "%%a" ) )

更多推荐

批处理文件未删除

本文发布于:2023-05-27 19:33:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/300578.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:批处理文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!