[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[文本处理] 一个拷贝文件计算拷贝时间和大小的BAT脚本

  1. echo.&echo ===== %folder% Recovery Desktop =====
  2. set time_begin=%time:~0,-3%
  3. echo d | xcopy /s /y %folder%\%username%\desktop %userprofile%\desktop >nul
  4. set time_end=%time:~0,-3%
  5. call :_difftime %time_begin% %time_end%
  6. Set SDir=%folder%\%username%\desktop
  7. Set TDir=%userprofile%\desktop
  8. Call :info %SDir% %TDir%
  9. echo Source:%SDirs% Floders,%SFiles% Files,%Ssize% Bytes.
  10. echo Target:%TDirs% Floders,%TFiles% Files,%Tsize% Bytes.
  11. echo Recovery Completed. Use Time: %hour_% Hr %munite_% Min %second_% Sec
  12. pause
  13. goto :BackupTools
  14. :_difftime <time_begin> <time_end>
  15. for /f "tokens=1,2,3 delims=:" %%i in ("%time_begin%") do (
  16.     set /a hour_b=%%i
  17.     set /a munite_b=%%j
  18.     set /a second_b=%%k
  19. )
  20. for /f "tokens=1,2,3 delims=:" %%i in ("%time_end%") do (
  21.     set /a hour_a=%%i
  22.     set /a munite_a=%%j
  23.     set /a second_a=%%k
  24. )
  25. if %second_a% lss %second_b% (
  26.     set /a munite_a=%munite_a%-1
  27.     set /a second_a=%second_a%+60
  28. )
  29. set /a second_=%second_a%-%second_b%
  30. if %munite_a% lss %munite_b% (
  31.     set /a hour_a=%hour_a%-1
  32.     set /a munite_a=%munite_a%+60
  33. )
  34. set /a munite_=%munite_a%-%munite_b%
  35. if %hour_a% lss %hour_b% (
  36.     set /a hour_a=%hour_a%+24
  37. )
  38. set /a hour_=%hour_a%-%hour_b%
  39. Goto :eof
  40. :info <SDir> <TDir>
  41. set /a Ssize=0
  42. set /a Tsize=0
  43. :仅统计文件数量
  44. for /f "tokens=1* delims= " %%a in ('dir/a-d/s /b "%Sdir%"^|find /v /c ""') do set SFiles=%%~a
  45. :统计文件夹
  46. for /f "tokens=1* delims= " %%a in ('dir/ad /b /s "%Sdir%"^|find /v /c ""') do set SDirs=%%~a
  47. :文件容量大小
  48. for /f "tokens=3* delims= " %%a in ('dir/a-d/s "%Sdir%"^|findstr /c:"File(s)"') do set Ssize=%%~a
  49. for /f "tokens=1* delims= " %%a in ('dir/a-d/s /b "%Tdir%"^|find /v /c ""') do set TFiles=%%~a
  50. for /f "tokens=1* delims= " %%a in ('dir/ad /b /s "%Tdir%"^|find /v /c ""') do set TDirs=%%~a
  51. for /f "tokens=3* delims= " %%a in ('dir/a-d/s "%Tdir%"^|findstr /c:"File(s)"') do set Tsize=%%~a
  52. Goto :eof
复制代码

返回列表