我创建了一个.bat
文件,用于将新文件上传到我公司的服务器。它运行良好,但运行后,我不知道哪些文件是新的,哪些是相同的。当批处理文件运行时,我可以看到它何时弹出为新的,何时弹出为相同的,但我想创建一个日志文件来显示哪些文件是新的,不包括未上传的文件。
目前,这是我的.bat
文件:
robocopy "C:\HUSAPOGDATA\Product_Library" "\\NOAMSNYW024.noam.heiway.net\NationalAccounts\Category Management\Space Planning Images\Product_Library" beer.mdb
robocopy "C:\HUSAPOGDATA\Product_Library" "\\NOAMSNYW024.noam.heiway.net\NationalAccounts\Category Management\Space Planning Images\Product_Library" SMSB_Library.mdb
robocopy "C:\Pog Images\Images\Beer" "\\NOAMSNYW024.noam.heiway.net\NationalAccounts\Category Management\Space Planning Images\Pog Images\Images\Beer" /E *.1 *.2 *.3 *.7 *.8 *.9 /MIR /S /V /NP /ZB
我使用下面的命令来记录数据,
fromlocal2network_productlibrary_new.bat > C:\Merch\log.txt
但我不想要所有的命令输出,因为上传了数千个文件,文件变得非常大。有没有办法在日志文件中将新文件与旧文件分开?
答案1
添加语法示例: /LOG+:%Log%
来源(下): Robocopy /?
::
:: Logging Options :
::
/L :: List only - don't copy, timestamp or delete any files.
/X :: report all eXtra files, not just those selected.
/V :: produce Verbose output, showing skipped files.
/TS :: include source file Time Stamps in the output.
/FP :: include Full Pathname of files in the output.
/BYTES :: Print sizes as bytes.
/NS :: No Size - don't log file sizes.
/NC :: No Class - don't log file classes.
/NFL :: No File List - don't log file names.
/NDL :: No Directory List - don't log directory names.
/NP :: No Progress - don't display % copied.
/ETA :: show Estimated Time of Arrival of copied files.
/LOG:file :: output status to LOG file (overwrite existing log).
/LOG+:file :: output status to LOG file (append to existing log).
/UNILOG:file :: output status to LOG file as UNICODE (overwrite existing
log).
/UNILOG+:file :: output status to LOG file as UNICODE (append to existing
log).
/TEE :: output to console window, as well as the log file.
/NJH :: No Job Header.
/NJS :: No Job Summary.
/UNICODE :: output status as UNICODE.
答案2
首先添加 /XO 标志来负责从输出中删除旧文件。
然后,为了进一步最小化生成的 RoboCopy 日志中的输出,您可以添加以下标志:/NDL /NS /NC。
注意:仅在测试命令并发现类信息(即旧文件)已从输出中删除后才使用 /NC。使用 /L 标志进行测试。此标志用于对命令进行“假设”;实际上没有文件被移动。
除了您已有的标志之外,使用这四个标志应该会很好用。您可以删除的其他输出(文件名列表除外)只有作业标题和摘要。这将成为您的一个选项。
毫不犹豫地使用 /Tee 选项来创建日志,并在命令行中直观地查看实时结果。为此,您只需添加 /Tee /Log:%Log%