windows 如何避免在日志文件中记录命令时存储CMD的膨胀输出?

woobm2wo  于 2023-02-16  发布在  Windows
关注(0)|答案(1)|浏览(153)

所有人。
我在一个CMD批处理脚本中使用RobocopyWinRAR。我惊讶地看到日志文件很大,而且充满了膨胀。WinRAR膨胀并没有那么糟糕。但是,Robocopy输出太膨胀了。因为它复制了大文件(300 + GB)。
下面是我使用的Robocopy命令:

robocopy /Z /B /ZB /J /X /V /TS /FP /ETA /TEE /LOG+:"C:\log.txt" "D:\Data" "E:\Data"

以下是日志文件中Robocopy的输出(删除了大部分行以总结问题):

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                              
-------------------------------------------------------------------------------

  Started : Sunday, February 12, 2023 9:42:25 AM
   Source : D:\Data
     Dest : E:\Data

    Files : *.*
        
  Options : *.* /V /X /TS /FP /TEE /DCOPY:DA /COPY:DAT /ZB /J /ETA /R:1000000 /W:30 

------------------------------------------------------------------------------

                       3    D:\Data
        Newer             39.1 m 2023/02/12 00:00:25    D:\Data\abc.iso
  0.1%
  0.2%
  0.4%
  0.5%
  0.7%
  0.8%
  1.0%
  1.1%
  1.3%
  1.4%
  1.6%
  1.7%
  1.9%
  2.0%
  2.2%
  2.3%
  2.5%
  2.6%
  2.8%
  2.9%
  3.1%
  3.2%
  3.4%
... (Deleted the lines between because they are too long)
 97.1%
 97.2%
 97.4%
 97.5%
 97.7%
 97.8%
 98.0%
 98.1%
 98.3%
 98.4%
 98.6%
 98.7%
 98.9%
 99.0%
 99.2%
 99.3%
 99.5%
 99.6%
 99.8%
 99.9%
100%

下面是WinRAR命令:

rar a -ag -ep -m5 -md1024m D:\compressed_data D:\data.iso -p1234 >> C:\log_compress.txt

以下是存储在日志文件中的WinRAR命令的输出:

RAR 4.20   Copyright (c) 1993-2012 Alexander Roshal   9 Jun 2012
Trial version             Type RAR -? for help

Evaluation copy. Please register.

Creating archive D:\compressed_data20230211160436.rar

Adding    D:\data.iso                     0%  1%  2%  3%  4%  5%  6%  7%  8%  9% 10% 11% 12% 13% 14% 15% 16% 17% 18% 19% 20% 21% 22% 23% 24% 25% 26% 27% 28% 29% 30% 31% 32% 33% 34% 35% 36% 37% 38% 39% 40% 41% 42% 43% 44% 45% 46% 47% 48% 49% 50% 51% 52% 53% 54% 55% 56% 57% 58% 59% 60% 61% 62% 63% 64% 65% 66% 67% 68% 69% 70% 71% 72% 73% 74% 75% 76% 77% 78% 79% 80% 81% 82% 83% 84% 85% 86% 87% 88% 89% 90% 91% 92% 93% 94% 95% 96% 97% 98% 99%  OK 
Done

正如您所看到的,无论使用什么命令,百分比都会使日志文件膨胀。

5uzkadbs

5uzkadbs1#

要从ROBOCOPY命令中删除当前膨胀,可以添加/NP开关。感谢**@Stephan的注解**解决此问题。

robocopy /NP /LOG+:"C:\log.txt" "D:\Data" "E:\Data"

要从WinRAR命令中删除当前膨胀,可以通过添加-idp开关来完成。感谢**@Mofi的评论**解决此问题。

rar a -idp D:\compressed_data D:\data.iso >> C:\log_compress.txt

相关问题