China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-06-27 05:11
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Automatically delete the specified file 100 days after the file is generated, and not in the trash can View 5,078 Replies 21
Floor 16 Posted 2007-01-20 11:56 ·  中国 重庆 江北区 电信
新手上路
Credits 16
Posts 8
Joined 2007-01-20 11:09
19-year member
UID 77138
Gender Male
Status Offline
But everyone's enthusiasm is worthy of recognition.
Floor 17 Posted 2007-01-20 13:03 ·  中国 上海 杨浦区 电信
高级用户
★★
Credits 653
Posts 252
Joined 2006-04-16 19:48
20-year member
UID 53939
Status Offline
Originally posted by xiaoqiangzx at 2007-1-16 09:47:
First of all, I very much admire everyone's professional knowledge and enthusiasm for learning~~
 I, the younger brother, have something to say
DOS is not like C++, can it be simple? ~~~
 Don't make it seem very profound, be popular...


It is not okay to use the task scheduler to run the delete command every 100 days, because the LZ requires deleting files that are 100 days ago, not deleting files every 100 days. The difference between these should be very obvious, right?

For example: A file created on the 99th day should be deleted on the 199th day. If you don't calculate and judge, and directly kill everything every 100 days, a file created on the 99th day will be deleted the next day.
Floor 18 Posted 2007-01-20 17:32 ·  中国 广东 广州 天河区 电信
金牌会员
★★★★
一叶枝头,万树皆春
Credits 2,564
Posts 1,127
Joined 2006-12-25 22:57
19-year member
UID 74552
Gender Male
Status Offline
Writing this is the most tiring

@ECHO OFF
:TOP0
FOR /L %%i IN (1,1,12) DO SET /A M%%i=30+(%%i+%%i/8)%%2
CALL :ALG M %DATE:~5,2%&&CALL :ALG ND %DATE:~8,2%
SET /A DAY=125-ND,NY=%DATE:~0,4%
:TOP1
CALL :CALC M2 ((NY-2000)%%4) -1)*-1+28 (
CALL :CALC M (M-1) -1)*-1*12+M-1 (
SET /A DAY-=M%M%,NY-=M/12
SET /A 1/((DAY+1)/DAY) 2>nul&&GOTO TOP1||GOTO START
:START
CALL :CALC DAY DAY *-DAY
CALL :CALC DM (M-1) -1)*-1*12*(((DAY*2/(DAY*2-1))-1)*-1)+(M+(DAY*2/(DAY*2-1)-1)) (
CALL :CALC DAY+ (M-DM)
SET /A DY=NY-DM/12
:TOOL
IF %DM% LSS 10 SET DM=0%DM%
IF %DAY% LSS 10 SET DAY=0%DAY%
ECHO %DY%-%DM%-%DAY%
FOR /R F: %%i IN (*.exe) DO CALL :CHKDEL %%i %%~ti
pause
GOTO :EOF

:CHKDEL
IF "%2" == "%DY%-%DM%-%DAY%" ECHO %2 -- %1
GOTO :EOF
:CALC
SET /A %1=%4((%2*2+1)%%2*%2*10)/%5((%2*2+1)%%2*%2*10-1)%3
GOTO :EOF
:ALG
SET CHKALG=%2
SET /A %1=%CHKALG:~0,1%*10+%CHKALG:~-1%
GOTO :EOF
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
qzwqzw +9 2007-02-01 11:20
Floor 19 Posted 2007-01-21 08:40 ·  中国 广东 广州 番禺区 电信
初级用户
Credits 20
Posts 8
Joined 2007-01-08 22:25
19-year member
UID 75862
Gender Male
Status Offline
Everyone thinks there should be code execution, and the thinking is a bit rigid. The brother on the 13th floor is very good.
Floor 20 Posted 2007-01-21 11:30 ·  中国 江苏 苏州 广电网(移动出口)
初级用户
Credits 72
Posts 35
Joined 2006-11-13 01:26
19-year member
UID 70380
Gender Male
Status Offline
For example, to delete the files under the D:\C1 folder. Using the forfiles that comes with Microsoft Windows 2003 is really a tenth of the effort but a hundred times the result.
forfiles /p D:\C1 /d -100 /c "cmd /c del @file"


[ Last edited by aspirer on 2007-1-20 at 10:32 PM ]
Floor 21 Posted 2007-03-23 06:06 ·  中国 广东 深圳 电信
初级用户
Credits 59
Posts 28
Joined 2007-03-23 05:18
19-year member
UID 82622
Gender Male
Status Offline
The understanding of building 13 is incorrect, but the idea is good.
The idea of building 20 is also not bad.
But it only runs under 2003.
Floor 22 Posted 2008-03-07 11:06 ·  中国 新疆 昌吉回族自治州 电信
新手上路
Credits 12
Posts 5
Joined 2008-01-21 17:13
18-year member
UID 109187
Gender Male
Status Offline
A bit complicated, can't understand it very well, but still thank you.
Forum Jump: