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-10-01 19:18
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Asking for "a bat for regularly cleaning folders" (waiting for the 2nd day) View 3,172 Replies 16
Floor 16 Posted 2009-12-17 11:47 ·  中国 上海 电信
新手上路
★
Credits 10
Posts 10
Joined 2009-12-14 14:59
16-year member
UID 156571
Gender Male
Status Offline
After researching for a long time, it still doesn't work.

If you only delete files before a certain point in time, you can write it like this:

CODE: [Copy to clipboard]
--------------------------------------------------------------------------------

for /f "skip=5 tokens=1,2,3,4,5,7* delims=-:/ " %%i in ('dir "路径" /a:-d /t:c') do if not "%%m" == "" if "%%i%%j%%k%%l%%m" lss "时间" @del "路径\%%n%%o" /a /f /q>nul 2>nul
Floor 17 Posted 2009-12-17 12:45 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
@echo off
set a=d:\视频 recording materials
set t=201009021501
for /f "skip=5 tokens=1,2,3,4,5,7* delims=-:/ " %%i in ('dir "%a%" /a:-d /t:c') do if not "%%m" == "" if "%%i%%j%%k%%l%%m" lss "%t%" echo "%a%\%%n%%o"
echo The test directory is %a%
echo The separated time is %t:~0,4% years %t:~4,2% months %t:~6,2% days %t:~8,2% hours %t:~10,2% minutes
pause>nul

"The "d:\视频 recording materials" is the directory to be checked. The time point is set to September 2, 2010, 15:01.
Use this to test. Does the list not display all the files in this folder? Please post the displayed results as a picture.
Specifically, why doesn't it work?

[ Last edited by Hanyeguxing on 2009-12-17 at 12:56 ]
Forum Jump: