标题: [文本处理] 一个拷贝文件计算拷贝时间和大小的BAT脚本 [打印本页]
作者: wom087 时间: 2023-12-29 20:19 标题: 一个拷贝文件计算拷贝时间和大小的BAT脚本
- echo.&echo ===== %folder% Recovery Desktop =====
- set time_begin=%time:~0,-3%
- echo d | xcopy /s /y %folder%\%username%\desktop %userprofile%\desktop >nul
- set time_end=%time:~0,-3%
- call :_difftime %time_begin% %time_end%
- Set SDir=%folder%\%username%\desktop
- Set TDir=%userprofile%\desktop
- Call :info %SDir% %TDir%
- echo Source:%SDirs% Floders,%SFiles% Files,%Ssize% Bytes.
- echo Target:%TDirs% Floders,%TFiles% Files,%Tsize% Bytes.
- echo Recovery Completed. Use Time: %hour_% Hr %munite_% Min %second_% Sec
- pause
- goto :BackupTools
-
- :_difftime <time_begin> <time_end>
- for /f "tokens=1,2,3 delims=:" %%i in ("%time_begin%") do (
- set /a hour_b=%%i
- set /a munite_b=%%j
- set /a second_b=%%k
- )
- for /f "tokens=1,2,3 delims=:" %%i in ("%time_end%") do (
- set /a hour_a=%%i
- set /a munite_a=%%j
- set /a second_a=%%k
- )
- if %second_a% lss %second_b% (
- set /a munite_a=%munite_a%-1
- set /a second_a=%second_a%+60
- )
- set /a second_=%second_a%-%second_b%
- if %munite_a% lss %munite_b% (
- set /a hour_a=%hour_a%-1
- set /a munite_a=%munite_a%+60
- )
- set /a munite_=%munite_a%-%munite_b%
-
- if %hour_a% lss %hour_b% (
- set /a hour_a=%hour_a%+24
- )
- set /a hour_=%hour_a%-%hour_b%
- Goto :eof
-
- :info <SDir> <TDir>
- set /a Ssize=0
- set /a Tsize=0
- :仅统计文件数量
- for /f "tokens=1* delims= " %%a in ('dir/a-d/s /b "%Sdir%"^|find /v /c ""') do set SFiles=%%~a
- :统计文件夹
- for /f "tokens=1* delims= " %%a in ('dir/ad /b /s "%Sdir%"^|find /v /c ""') do set SDirs=%%~a
- :文件容量大小
- for /f "tokens=3* delims= " %%a in ('dir/a-d/s "%Sdir%"^|findstr /c:"File(s)"') do set Ssize=%%~a
- for /f "tokens=1* delims= " %%a in ('dir/a-d/s /b "%Tdir%"^|find /v /c ""') do set TFiles=%%~a
- for /f "tokens=1* delims= " %%a in ('dir/ad /b /s "%Tdir%"^|find /v /c ""') do set TDirs=%%~a
- for /f "tokens=3* delims= " %%a in ('dir/a-d/s "%Tdir%"^|findstr /c:"File(s)"') do set Tsize=%%~a
- Goto :eof
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |