『第
2 楼』:
扫描D:\rec\目录,不包括隐藏系统属性文件,不包括子目录:
@echo off&setlocal enabledelayedexpansion
set Date_D=%date:~0,10%
for /f "tokens=1,2 delims=:" %%a in ("%time%") do (
set Time_H=%%a&set Time_M=%%b
if "!Time_M:~0,1!"=="0" set Time_M=!Time_M:~1!
set/a Time_M-=20
if !Time_M! lss 0 set/a Time_H-=1,Time_M+=60
if !Time_H! lss 0 set Time_H=23&call:Date_D,1)
set Time_H=0%Time_H%&set Time_M=0%Time_M%&set Date_D=%Date_D% !Time_H:~-2!:!Time_M:~-2!&set Date_M=!Date_D::=-!
for %%a in ("D:\rec\*.*") do if "%Date_D%" leq "%%~ta" ren "%%a" "%%~na-%Date_M%%%~xa"
pause&exit
:Date_D
for /f "tokens=1-3 delims=-:/ " %%a in ("%date%") do (
set Date_Y=%%a&set Date_M=%%b&set Date_D=%%c
if "!Date_M:~0,1!"=="0" set Date_M=!Date_M:~1!
if "!Date_D:~0,1!"=="0" set Date_D=!Date_D:~1!)
set/a Date_D-=%1
if %Date_D% gtr 0 goto:Date_Y
:Date_M
set/a Date_M-=1
if !Date_M!==0 set/a Date_Y-=1,Date_M=12
set/a "Date_T=^!(Date_M-2)","Date_R=(^!(Date_Y%%4)&^!^!(Date_Y%%100))|^!(Date_Y%%400)","Date_C=^!(Date_M-4)|^!(Date_M-6)|^!(Date_M-9)|^!(Date_M-11)","Date_D=Date_T*(28+Date_R)+Date_C*30+(^!Date_T&^!Date_C)*31+Date_D"
if %Date_D% leq 0 goto:Date_M
:Date_Y
set Date_M=0%Date_M%&set Date_D=0%Date_D%&set Date_D=%Date_Y%-!Date_M:~-2!-!Date_D:~-2! [ Last edited by Hanyeguxing on 2010-6-11 at 15:05 ]
|