[英]Robocopy to show percentages but not each file being copied
I've been reverse engineering other code (being that I don't know much about batch writing at all) to backup specific subfolders.我一直在对其他代码进行逆向工程(因为我对批处理编写知之甚少)来备份特定的子文件夹。 Right now, it looks like this:
现在,它看起来像这样:
@echo off
for /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%a
mkdir "e:\Family Sync Folder Backup\%date:/=_%"
set source= "\\jessica\Family Sync Folder"
set destination= "e:\Family Sync Folder Backup\%date:/=_%"
robocopy %source% %destination% /e
This code is repeated for specific subfolders.对特定子文件夹重复此代码。 I was wondering if there was a way to print onto screen something like "Currently Backing Up (FOLDER NAME)" followed by a percentage but without listing each file.
我想知道是否有一种方法可以在屏幕上打印诸如“当前备份(文件夹名称)”之类的内容,后跟一个百分比,但不列出每个文件。
Bonus points for creating a log file which does display each file copied.创建显示每个复制文件的日志文件的奖励积分。
You can use您可以使用
robocopy %source% %destination% /e /LOG:"YourLogFile.txt"
to force robocopy into writing a log, or, to supress robocopy output and log at the same time you can强制 robocopy 写入日志,或者,同时抑制 robocopy 输出和日志,您可以
robocopy %source% %destination% /e >> YourLogFile.txt
Now, notice that most of Robocopy's output on screen will be supressed and will put you a blank blinking line until its over, to use this second option you'll have to write down a different method to copy in a batch so you can (on each iteration) get the actual number of files/folders copied (times 100) and divide by the total amount to get the % completed and display it on screen.现在,请注意 Robocopy 在屏幕上的大部分输出都将被抑制,并且会显示一个空白闪烁行直到结束,要使用第二个选项,您必须写下一个不同的方法来批量复制,以便您可以(在每次迭代)获取复制的文件/文件夹的实际数量(乘以 100)并除以总数以获得完成百分比并将其显示在屏幕上。
if you want to display a different progress indication you'll need the total amount of files and the amount of files copied, for that you'll end up using a for loop with dir command and probably lose the whole functionality of robocopy.如果您想显示不同的进度指示,您将需要文件总数和复制的文件数量,因为您最终将使用带有 dir 命令的 for 循环,并且可能会失去 robocopy 的全部功能。 Or you can get use of these 5 options on robocopy:
或者您可以在 robocopy 上使用这 5 个选项:
robocopy %source% %destination% /mir /LOG+:Yourfile.txt /NFL /NDL /NJH /NJS /nc /ns
/NFL : No File List - don't log file names.
/NDL : No Directory List - don't log directory names.
/NJH : No Job Header.
/NJS : No Job Summary.
Ctrl+v'd from: How can I make robocopy silent in the command line except for progress? Ctrl+v'd from: 除了进度之外,我怎样才能让 robocopy 在命令行中保持静默?
Note that % progress is shown per file on robocopy but not per directory.请注意,在 robocopy 上显示每个文件的进度百分比,而不是每个目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.