注意了啊 归档文件已有相同会直接覆盖的 本人在XP sp3系统使用正常
补充 使用方法将代码复制到文本文件中另存为新建文本.bat 双击运行 自动整理今天的文件到归档文件夹下
这是我从
批处理之家淘到的 相当实用整理桌面 自动把桌面上今天的处理文件和下载的文件自动归档到以日期为名 的文件夹中
大家也可以拿来用用
1 除了归档文件已有相同会直接覆盖的 其余好像已经比较完美了 本批处理只处理桌面上产生的文件
========================================================
@echo off
set "s=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
for /f "tokens=2*" %%i in ('reg query "%s%" /v Desktop') do (
set "Desktop=%%j"
)
for /f %%i in ('wmic os get LocalDateTime^|findstr /b [0-9]') do (
set "Today=%%i"
)
set "Today=%Today:~0,8%"
md "%Desktop%\归档\%Today%\" 2>nul
set "MyPath=%Desktop:~2%\"
set wql=where "drive='%Desktop:~0,2%' and path='%MyPath:\=\\%' and extension!='LNK'"
for /f "tokens=1*" %%i in ('wmic datafile %wql% get creationdate^,name^|findstr /b %Today%')do (
for /f "delims=" %%j in ("%%j") do (
if /i not "%%~fj" == "%~f0" move "%%~fj" "%Desktop%\归档\%Today%\"
)
)
pause
========================================================
2中方法 此方有些问题 还在改进 不建议使用
@echo off
set "s=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
for /f "tokens=2*" %%i in ('reg query "%s%" /v Desktop') do (
set "Desktop=%%j"
)
set "MyPath=%Desktop:~2%\"
set wql=where "drive='%Desktop:~0,2%' and path='%MyPath:\=\\%' and extension!='LNK'"
(for /f "tokens=1*" %%i in ('wmic datafile %wql% get creationdate^,name^|find "\"') do (
set "D=%%i"
setlocal enabledelayedexpansion
for %%k in ("%Desktop%\归档\!D:~0,8!") do (
endlocal
for /f "delims=" %%j in ("%%j") do (
if /i not "%%~fj" == "%~f0" (
md "%%~k\"
move "%%~fj" "%%~k\"
)
)
)
)) 2>nul
===============================================================