|
- @echo off
- setlocal enabledelayedexpansion
- set title=按文件日期归类
- title %title%
- ::需要归类的目录
- pushd %~dp0\test
- for /f %%a in ("%date:/=-%") do set "today=%%a"
- for /f %%a in ('dir /b *.txt 2^>nul') do (
- for /f %%b in ("%%~ta") do (
- set "filedate=%%b"
- set "filedate=!filedate:/=-!"
- if not "!filedate!"=="%today%" (
- set /a n+=1
- set "list_!n!_file=%%~nxa"
- set "list_!n!_date=!filedate!"
- )
- )
- )
- if !n! EQU 0 (
- color 4f
- echo;无文件可归类!
- ) else (
- for /l %%a in (1 1 !n!) do (
- title %title% %%a/!n!
- echo 正在移动 !list_%%a_file!
- if not exist "!list_%%a_date!" mkdir "!list_%%a_date!"
- move !list_%%a_file! !list_%%a_date!\ >nul
- )
- echo;
- echo;
- echo;文件按日期归类完毕!
- color 2f
- )
- echo;
- pause
复制代码 |
|