回复 4# 304802301
- @echo off
- rem 保存为ansi
- rem 代码使用winrar\下的rar.exe,使用需添加到系统环境变量,或者写明绝对路径
- cd /d "%~dp0"
- set pwd=QWEasd
- set f1=D:\实例_20240731_151654\A
- set f2=D:\实例_20240731_151654\C
- set log=d:\1.txt
-
- md "%f2%" 2>nul
- pushd "%f1%"
- call :getdt d
- (for /d %%d in (*) do (
- pushd "%%d"
- for /f "delims=" %%a in ('forfiles /s /m * /c "cmd /c if @isdir equ FALSE echo @relpath"') do (
- call :getdt
- set /p="%%~dpa,%%~nxa,"<nul
- rar a "%f2%\%%d.zip" -p%d%%pwd% "%%~a" 1>nul 2>nul
- if errorlevel 1 (
- echo 压缩失败
- ) else (
- echo 压缩成功
- )
- )
- popd
- ))>>"%log%"
- pause
- exit
-
- :getdt
- for /f %%a in ('wmic os get localdatetime ^|findstr [0-9]') do (
- set t=%%a
- )
- if "%~1" equ "d" (
- set %~1=%t:~0,4%%t:~4,2%%t:~6,2%
- ) else (
- set /p="%t:~0,4%年%t:~4,2%月%t:~6,2%日%t:~8,2%时%t:~10,2%分%t:~12,2%秒,"<nul
- )
- exit /b
复制代码
|