多谢11楼、27楼两位大佬提醒
重新写了一个,尽量排除 不同系统或者个性化设置导致的日期时间格式不同影响。- @echo off
- cd /d "%~dp0"
- for /f %%a in ('wmic os get localdatetime ^| findstr [0-9]') do (
- set d=%%a
- )
- set d=%d:~0,4%-%d:~4,2%-%d:~6,2%
- cd.>d.d
- for /f "tokens=1*" %%i in ('dir /tc "d.d" ^| findstr "d\.d$"') do (
- for %%a in (%%j) do (
- set /a n+=1
- )
- set _d=%%i
- )
- del d.d
- for /f "tokens=%n%*" %%a in ('dir /tc ^| findstr "^%_d%" ^| findstr /iv "\.$ \.cmd$ \.bat$ [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$"') do (
- if exist "%%b\" (
- robocopy "%%b" "%d%\%%b" /e /move
- ) else (
- robocopy . "%d%" "%%b" /mov
- )
- )
- pause
复制代码
|