|
本帖最后由 ppll2030 于 2023-9-9 17:56 编辑
已修正,无文件转移就不生成文件夹- @echo off
- title: 查找和移动非当天创建的文件到前一天命名的文件夹中
- for /f "tokens=3" %%i in ('reg query "HKCU\Control Panel\International" ^| findstr /ilc:"sShortDate"') do set sShortDate=%%i
- for /f "tokens=2,*" %%j in ('reg query "HKCU\Control Panel\International" ^| findstr /ilc:"sTimeFormat"') do set sTimeFormat="%%k"
- reg add "HKCU\Control Panel\International" /f /v "sShortDate" /t REG_SZ /d "yyyy/MM/dd" >nul
- reg add "HKCU\Control Panel\International" /f /v "sTimeFormat" /t REG_SZ /d "HH:mm:ss" >nul
- (echo yd=Date(^)-1
- echo wscript.echo yd
- ) > yd.vbs
- for /f %%a in ('cscript yd.vbs') do set yd=%%a
- del /q yd.vbs
- SET YYD=%yd:/=-%
- echo.&echo 即将把%date%以前(不含当日)创建的文件全部转移到%YYD%文件夹下。
- echo.&pause
- set p=c:\sample
- FOR /f "tokens=3,*" %%a IN ('dir /a-d /tc %p% ^| findstr /ilc:"/" ^| FINDSTR /ilvc:"%date%"') DO (
- if not exist %p%\%YYD% md %p%\%YYD%
- move "%p%\%%b" "%p%\%YYD%") >nul 2>nul
-
- reg add "HKCU\Control Panel\International" /f /v "sShortDate" /t REG_SZ /d "%sShortDate%" >nul
- reg add "HKCU\Control Panel\International" /f /v "sTimeFormat" /t REG_SZ /d "%sTimeFormat%" >nul
- cls&echo.&echo %date%以前创建的文件转移完成。
- timeout /t 2 >nul
复制代码
|
评分
-
查看全部评分
|