|
yuehong
初级用户
 
积分 64
发帖 37
注册 2007-3-14
状态 离线
|
『第 31 楼』:
使用 LLM 解释/回答一下
Originally posted by dddyjq1 at 2008-10-21 01:15 AM:
翻个老贴给你 ,测试成功的
@echo off
SET TT=1
set p1=%date:~0,4%
set p2=%date:~5,2%
set p3=%date:~8,2%
setlocal enabledelayedexpansion
for /l %%a in (1,1,3) do (
for /f "del ...
2000下面还是不行
出现:
此时不应有 "。
此时不应有 "。
此时不应有 "。
此时不应有 "。
此时不应有 "。
Originally posted by dddyjq1 at 2008-10-21 01:15 AM:
Turn over an old post for you, tested and successful
@echo off
SET TT=1
set p1=%date:~0,4%
set p2=%date:~5,2%
set p3=%date:~8,2%
setlocal enabledelayedexpansion
for /l %%a in (1,1,3) do (
for /f "del ...
Still not working under 2000
Appears:
There should not be "at this time.
There should not be "at this time.
There should not be "at this time.
There should not be "at this time.
There should not be "at this time.
|
|
2008-10-21 18:38 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 32 楼』:
使用 LLM 解释/回答一下
我这边的情况:
@echo off
set TT=5&set "ph=d:\000"
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%%100
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1,p2=12
set/a PN2="!(p1%%4)&!(!(p1%%100))|!(p1%%400)",PN2=28+PN2
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3+=%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3-=tt
setlocal enabledelayedexpansion
for %%i in (p2 p3) do if !%%i! lss 10 set %%i=0!%%i!
for /f "skip=7 tokens=1,3*" %%i in ('dir /ad /tc "%ph%" 2^>nul^|find /v "字节"') do (
if %p1%-%p2%-%p3% gtr %%i echo rd /s /q "%ph%\%%k"
)
pause&exit
My situation here:
@echo off
set TT=5&set "ph=d:\000"
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%%100
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1,p2=12
set/a PN2="!(p1%%4)&!(!(p1%%100))|!(p1%%400)",PN2=28+PN2
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3+=%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3-=tt
setlocal enabledelayedexpansion
for %%i in (p2 p3) do if !%%i! lss 10 set %%i=0!%%i!
for /f "skip=7 tokens=1,3*" %%i in ('dir /ad /tc "%ph%" 2^>nul^|find /v "字节"') do (
if %p1%-%p2%-%p3% gtr %%i echo rd /s /q "%ph%\%%k"
)
pause&exit
附件
1: aaa.gif (2008-10-21 19:48, 4.97 KiB, 下载附件所需积分 1 点
)
|

简单!简单!再简单! |
|
2008-10-21 19:48 |
|
|
yuehong
初级用户
 
积分 64
发帖 37
注册 2007-3-14
状态 离线
|
『第 33 楼』:
使用 LLM 解释/回答一下
Originally posted by terse at 2008-10-21 07:48 PM:
我这边的情况:
@echo off
set TT=5&set "ph=d:\000"
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%% ...
测试成功,感谢!!
要是d:\000下面的文件也要删除呢?怎么处理?麻烦了。。。
Originally posted by terse at 2008-10-21 07:48 PM:
Here is my situation:
@echo off
set TT=5&set "ph=d:\000"
for /f "tokens=1-3 delims=-/\:. " %%i in ("%date%") do set /a p1=%%i,p2=100%%j%%100,p3=100%%k%% ...
Test successful, thanks!
If you also need to delete the files under d:\000, how to handle it? It's troublesome...
|
|
2008-10-21 22:09 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 34 楼』:
使用 LLM 解释/回答一下
Originally posted by yuehong at 2008-10-21 22:09:
测试成功,感谢!!
要是d:\000下面的文件也要删除呢?怎么处理?麻烦了。。。
其实这个就是我20楼 给你的 你竟然顶到这里
删文件 你要先dir /a-d /b 然后 判断时间 后 del
Originally posted by yuehong at 2008-10-21 22:09:
Test successful, thank you!!
What if the files under d:\000 also need to be deleted? How to handle it? It's troublesome...
Actually, this is what I gave you on floor 20. You actually bumped it up here.
To delete files, you need to first dir /a-d /b, then judge the time, and then del
|

简单!简单!再简单! |
|
2008-10-21 23:13 |
|
|
aphasia
新手上路

积分 1
发帖 1
注册 2008-10-27
状态 离线
|
|
2008-10-27 16:18 |
|
|
qwertl
中级用户
  
积分 461
发帖 243
注册 2007-10-14
状态 离线
|
『第 36 楼』:
使用 LLM 解释/回答一下
在win2003下正常删
set FileDate=2008-10-27 22:20
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! LSS 20081018 (echo ....)
在win2000下要怎样改这个代码呢?
set FileDate=08-10-22 17:56
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! LSS 20081023 (echo ....)
set desfolder=e:\rardata
setlocal enabledelayedexpansion
>"%tmp%\MyDel.vbs" echo dt=date()-11
>>"%tmp%\MyDel.vbs" echo s=right(year(dt),4) ^& right("0" ^&
month(dt),2) ^& right("0" ^& day(dt),2)
>>"%tmp%\MyDel.vbs" echo wscript.echo s
for /f %%a in ('cscript /nologo "%tmp%\MyDel.vbs"') do set DateFlag=%%a
echo %DateFlag%
pause
for /f "tokens=*" %%a in ('dir /s /b /a-d "%desfolder%"') do (
set FileDate=%%~ta 这里取得的文件日期与xp 及2003不同.
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! lss %DateFlag% (
echo "%%a"
)
)
pause
In Windows 2000, for the code:
First, for the part of handling `FileDate`:
The original code for setting `FileDate` in Windows 2000:
```
set FileDate=08-10-22 17:56
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! LSS 20081023 (echo ....)
```
Since in Windows 2000, the way of handling date format might have some differences, but the basic operations of replacing `-` and taking the first 8 characters are similar. Just make sure the date comparison is correct according to the actual situation.
For the part related to `MyDel.vbs`:
The code for creating and running the VBScript is the same in terms of logic. It calculates the date minus 11 days and then gets the formatted date string.
For the part of getting the file date and comparing:
The line `set FileDate=%%~ta` gets the file date and time. In Windows 2000, the format of `%%~ta` might be a bit different from XP and 2003, but the subsequent operations of replacing `-` and taking the first 8 characters are the same. Then comparing `!FileDate!` with `%DateFlag%` is the same logic.
The overall translated code remains as the original code structure but adjusted for the Windows 2000 environment considerations as described above.
The translated text of the entire code block as follows:
In win2003 it works normally to delete
set FileDate=2008-10-27 22:20
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! LSS 20081018 (echo ....)
How to modify this code under win2000?
set FileDate=08-10-22 17:56
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! LSS 20081023 (echo ....)
set desfolder=e:\rardata
setlocal enabledelayedexpansion
>"%tmp%\MyDel.vbs" echo dt=date()-11
>>"%tmp%\MyDel.vbs" echo s=right(year(dt),4) ^& right("0" ^&
month(dt),2) ^& right("0" ^& day(dt),2)
>>"%tmp%\MyDel.vbs" echo wscript.echo s
for /f %%a in ('cscript /nologo "%tmp%\MyDel.vbs"') do set DateFlag=%%a
echo %DateFlag%
pause
for /f "tokens=*" %%a in ('dir /s /b /a-d "%desfolder%"') do (
set FileDate=%%~ta The file date obtained here is different from that in xp and 2003.
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! lss %DateFlag% (
echo "%%a"
)
)
pause
|
|
2008-11-3 11:56 |
|
|