|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 16 楼』:
使用 LLM 解释/回答一下
。。
Last edited by flyinspace on 2008-8-21 at 04:45 PM ]
Last edited by flyinspace on 2008-8-21 at 04:45 PM ]
|

知,不觉多。不知,乃求知 |
|
2008-8-21 16:38 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 17 楼』:
使用 LLM 解释/回答一下
问下。你生成的文件名是什么?
20080812?之样的?
Ask. What is the file name you generated? 20080812? Like that?
|

知,不觉多。不知,乃求知 |
|
2008-8-21 16:42 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 18 楼』:
使用 LLM 解释/回答一下
顶楼有描述
2008-08-18
The top floor has a description
2008-08-18
|

 |
|
2008-8-21 16:49 |
|
|
flyinspace
银牌会员
    
积分 1206
发帖 517
注册 2007-3-25
状态 离线
|
『第 19 楼』:
使用 LLM 解释/回答一下
现在假设你的文件夹里的文件都是按日期生成的。(我不理是什么文件名了)
千万不要乱自己建立文件夹了哦。:)嘿嘿。
那么给你一个简单的代码。不过不太安全,你要保证里面的文件不可以乱
下面是一句话代码
skip 是指跳过前 5 条
for /f "skip=5 tokens=* " %%i in ('dir /b /o-d /ad-h-s') do echo 要删除的文件名为:,语法格式:
这里的代码可以测试,如果你发现满足你的条件。那么你就可以把rd那里的东西取出来了。。。。
记得,上面的条件是需要满足你说的每天建立一个备份文件夹的情况下才可以使用的。。而且该备份文件夹里不可以有其他的文件夹了。只能存在备份的文件。。
Last edited by flyinspace on 2008-8-21 at 04:59 PM ]
Now suppose all the files in your folder are generated by date. (I don't care what the file names are)
Don't mess with creating your own folders randomly. : ) Hehe.
Then here's a simple code. But it's not very safe, you need to ensure that the files are not messed up.
Here's a one - sentence code.
"skip" means skip the first 5.
for /f "skip=5 tokens=* " %%i in ('dir /b /o-d /ad-h-s') do echo The file name to delete is: , syntax format:
This code can be tested. If it meets your conditions, then you can take out the things after rd...
Remember, the above conditions need to be met under the condition that you said a backup folder is created every day. Moreover, there should be no other folders in this backup folder. Only backup files can exist.
Last edited by flyinspace on 2008 - 8 - 21 at 04:59 PM ]
|

知,不觉多。不知,乃求知 |
|
2008-8-21 16:51 |
|
|
terse
银牌会员
    
积分 2404
发帖 946
注册 2005-9-8
状态 离线
|
『第 20 楼』:
使用 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 rd /s /q "%ph%\%%k"
)
pause&exit
Translate an old post for you. I don't know if the time format matches yours
@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 rd /s /q "%ph%\%%k"
)
pause&exit
|

简单!简单!再简单! |
|
2008-8-21 18:01 |
|
|
qwertl
中级用户
  
积分 461
发帖 243
注册 2007-10-14
状态 离线
|
『第 21 楼』:
使用 LLM 解释/回答一下
vbs文件是否在windows98、xp\2000\2003系统下都可以运行的?
HAT的自动删N日前文件VBS似懂非懂 <img src="images/smilies/face-raspberry.png" align="absmiddle" border="0">
--------------------------------------------------------------------------------
我要在win2000下自动删除目录rardata下的15天前的文件,要怎样改呢?win2003下有forfile是比较方便.
@echo off
>"%temp%\MyDate.vbs" echo dt=date()-5
>>"%temp%\MyDate.vbs" echo s=right(year(dt),4) ^& "-" ^& right("0" ^& month(dt),2) ^& "-" ^& right("0" ^& day(dt),2)
>>"%temp%\MyDate.vbs" echo wscript.echo s
for /f %%a in ('cscript /nologo "%temp%\MyDate.vbs"') do set FiveDay=%%a
for /f %%a in ('dir /b /ad "D:\000"') do (
if "%%a" lss "%FiveDay%" (
rd /s /q "%%a"
)
)
Last edited by qwertl on 2008-8-23 at 10:56 PM ]
Are VBS files runnable under Windows 98, XP, 2000, 2003 systems?
HAT's automatic delete files N days ago VBS is somewhat incomprehensible :P
--------------------------------------------------------------------------------
I want to automatically delete files older than 15 days in the directory rardata under win2000. How to modify it? Forfile is more convenient under win2003.
@echo off
>"%temp%\MyDate.vbs" echo dt=date()-5
>>"%temp%\MyDate.vbs" echo s=right(year(dt),4) ^& "-" ^& right("0" ^& month(dt),2) ^& "-" ^& right("0" ^& day(dt),2)
>>"%temp%\MyDate.vbs" echo wscript.echo s
for /f %%a in ('cscript /nologo "%temp%\MyDate.vbs"') do set FiveDay=%%a
for /f %%a in ('dir /b /ad "D:\000"') do (
if "%%a" lss "%FiveDay%" (
rd /s /q "%%a"
)
)
Last edited by qwertl on 2008-8-23 at 10:56 PM ]
|
|
2008-8-23 22:46 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
『第 22 楼』:
Re 21楼
使用 LLM 解释/回答一下
@echo off
setlocal enabledelayedexpansion
set SrcDir=D:\rardata
>"%tmp%\MyDel.vbs" echo dt=date()-15
>>"%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
for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"') do (
set FileDate=%%~ta
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! lss %DateFlag% (
del /f /q "%%a"
)
)
```
@echo off
setlocal enabledelayedexpansion
set SrcDir=D:\rardata
>"%tmp%\MyDel.vbs" echo dt=date()-15
>>"%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
for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"') do (
set FileDate=%%~ta
set FileDate=!FileDate:-=!
set FileDate=!FileDate:~0,8!
if !FileDate! lss %DateFlag% (
del /f /q "%%a"
)
)
```
|

 |
|
2008-8-23 23:32 |
|
|
qwertl
中级用户
  
积分 461
发帖 243
注册 2007-10-14
状态 离线
|
『第 23 楼』:
使用 LLM 解释/回答一下
win2000的%data%是这样格式: 星期日 2008-08-24
The format of %data% in win2000 is: Sunday 2008-08-24
|
|
2008-8-24 18:58 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
|
2008-8-24 20:05 |
|
|
qwertl
中级用户
  
积分 461
发帖 243
注册 2007-10-14
状态 离线
|
『第 25 楼』:
使用 LLM 解释/回答一下
谢谢HAT的耐心指点!
现在看正找到延迟变量的内容,批处理的内容也真不少。<img src="images/smilies/face-raspberry.png" align="absmiddle" border="0">
如果要执行的批处理不存放在D:\rardata目录下,for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"') 的dir后要指定删去文件的目录路径吧?
这两句是起什么作用呢?
s=right(year(dt),4) ^& right("0" ^& month(dt),2) ^& right("0" ^& day(dt),2)
wscript.echo s
Last edited by qwertl on 2008-8-24 at 10:46 PM ]
Thanks for HAT's patient guidance!
Now I'm looking at the content of the delay variable, and there's really a lot of batch processing content. :P
If the batch processing to be executed is not stored in the D:\rardata directory, the dir after for /f "tokens=*" %%a in ('dir /s /b /a-d "%SrcDir%"') should specify the directory path of the file to be deleted, right?
What do these two sentences do?
s=right(year(dt),4) ^& right("0" ^& month(dt),2) ^& right("0" ^& day(dt),2)
wscript.echo s
Last edited by qwertl on 2008-8-24 at 10:46 PM ]
|
|
2008-8-24 22:31 |
|
|
HAT
版主
       
积分 9023
发帖 5017
注册 2007-5-31
状态 离线
|
|
2008-8-24 23:06 |
|
|
AppleWolf
初级用户
 
积分 110
发帖 41
注册 2007-3-31
状态 离线
|
『第 27 楼』:
使用 LLM 解释/回答一下
这个我写好了,用的方法比较老套
set usbdisk=E:
set befor2days=
set nowdate=
echo wscript.echo dateadd("d",-2,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set/a befor2days=%y%%m%%d%
echo wscript.echo dateadd("d",-0,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set/a nowdate = %y%%m%%d%
........中间省略,日期整理为:20080825 这种格式,并以此为目录。
dir %usbdisk%\ /ad/on/b>%tmp%\usbdir.tmp
for /f "delims=" %%i in (%tmp%\usbdir.tmp) do (
if %%i lss %befor2days% (
rd /s/q %usbdisk%\%%i
)
下面是判断是否是2天前的,如果是,就删,如果不是,就跳过。
希望各位高手不要笑我,我解决的办法有点笨。
I've finished this. The method used is relatively old-fashioned
set usbdisk=E:
set befor2days=
set nowdate=
echo wscript.echo dateadd("d",-2,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set/a befor2days=%y%%m%%d%
echo wscript.echo dateadd("d",-0,date) >%tmp%\tmp.vbs
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set y=%%i
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set m=%%j
for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo %tmp%\tmp.vbs') do set d=%%k
if %m% LSS 9 set m=0%m%
if %d% LSS 9 set d=0%d%
set/a nowdate = %y%%m%%d%
........Omit in the middle, the date is sorted into the format of 20080825 and used as the directory.
dir %usbdisk%\ /ad/on/b>%tmp%\usbdir.tmp
for /f "delims=" %%i in (%tmp%\usbdir.tmp) do (
if %%i lss %befor2days% (
rd /s/q %usbdisk%\%%i
)
下面 is to judge whether it is 2 days ago. If it is, delete it; if not, skip.
Hope the experts don't laugh at me. The solution I came up with is a bit clumsy.
|
|
2008-8-25 20:47 |
|
|
qwertl
中级用户
  
积分 461
发帖 243
注册 2007-10-14
状态 离线
|
『第 28 楼』:
使用 LLM 解释/回答一下
我们经常要在日常的工作中查找文件,要说linux下最强大的文件查找工具,非find莫属。find可以从文件名、读取修改时间、大小、类型等等来筛选文件,可以完成日常几乎所有的查找需求。
来看一个简单的例子:
find /tmp/ -name 'galeki*'
意思就是在/tmp目录下找出以“galeki”开头的文件,-name指出是对文件名进行筛选,是不是很简单明了?除了文件名,find还有更强大的筛选条件:
1.时间:
参数 意义
-atime n 上一次存取时间在n*24小时前以内的文件 用linux的find来实现是简单
-ctime n 上一次状态改变在n*24小时前以内的文件
-mtime n 上一次修改时间在n*24小时前以内的文件
-newer file 比file所指的文件还要新的文件
We often need to search for files in daily work. When it comes to the most powerful file search tool under Linux, find is definitely the one. find can filter files from file names, reading and modification times, sizes, types, etc., and can complete almost all daily search needs.
Let's take a simple example:
find /tmp/ -name 'galeki*'
This means finding files starting with "galeki" in the /tmp directory. -name indicates that it is filtering by file name. Isn't it very simple and clear? In addition to file names, find has more powerful filtering conditions:
1. Time:
Parameter Meaning
-atime n Files whose last access time was within n*24 hours Using Linux's find is simple
-ctime n Files whose last status change was within n*24 hours
-mtime n Files whose last modification time was within n*24 hours
-newer file Files that are newer than the file referred to by file
|
|
2008-9-15 02:09 |
|
|
yuehong
初级用户
 
积分 64
发帖 37
注册 2007-3-14
状态 离线
|
『第 29 楼』:
使用 LLM 解释/回答一下
没一个测试成功的。。
2000的时间格式为:
当前日期: 2008-10-20 星期一
希望哪位高手给个完整的
None of the tests succeeded..
The time format of 2000 is:
Current date: 2008-10-20 Monday
Hope some expert can give a complete one
|
|
2008-10-20 23:28 |
|
|
dddyjq1
初级用户
 
积分 175
发帖 108
注册 2008-5-19
状态 离线
|
『第 30 楼』:
使用 LLM 解释/回答一下
翻个老贴给你 ,测试成功的
@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 "delims=0 tokens=*" %%i in ("!p%%a!") do set p%%a=%%i
)
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1&&set p2=12
SET/a PN1=%p1%%%4
set PN2=28
if %PN1% EQU 0 set pN2=29
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3=%p3%+%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3=%p3%-%tt%
set p2=0%p2%
set p2=%p2:~-2,2%
set p3=0%p3%
set p3=%p3:~-2,2%
for /r "C:\新建文件夹\" %%i in (*.*) do set t=%%~ti &&call :loop "%%~fi"
pause
goto :eof
:loop
if not "%~1" == "%~f0" (
IF %p1%%p2%%p3% gtr %t:~0,4%%t:~5,2%%t:~8,2% del %1
)
Here's the translation:
Translate an old post for you, tested successfully
@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 "delims=0 tokens=*" %%i in ("!p%%a!") do set p%%a=%%i
)
if %p3% gtr %TT% goto ppp
:nxt
set/a p2-=1
if %p2% equ 0 set/a p1-=1&&set p2=12
SET/a PN1=%p1%%%4
set PN2=28
if %PN1% EQU 0 set pN2=29
for /f "tokens=%p2%" %%i in ("31 %pN2% 31 30 31 30 31 31 30 31 30 31") do set/a p3=%p3%+%%i
if %p3% leq %tt% goto nxt
:ppp
set/a p3=%p3%-%tt%
set p2=0%p2%
set p2=%p2:~-2,2%
set p3=0%p3%
set p3=%p3:~-2,2%
for /r "C:\New Folder\" %%i in (*.*) do set t=%%~ti &&call :loop "%%~fi"
pause
goto :eof
:loop
if not "%~1" == "%~f0" (
IF %p1%%p2%%p3% gtr %t:~0,4%%t:~5,2%%t:~8,2% del %1
)
|
|
2008-10-21 01:15 |
|