简体   繁体   English

Robocopy 显示百分比,但不显示正在复制的每个文件

[英]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.

相关问题 Robocopy 要复制的最大文件大小限制和 robocopy 的替代文件复制工具 - Robocopy max file size limit to be copied & alternative file copy tools to robocopy 如何防止文件在Windows文件系统中被复制或剪切? - How to prevent a file being copied or cut in windows file system? 查找是否在C ++中复制文件(在Windows中)? - Finding whether file is being copied or not in C++(in Windows)? 如何使用Python防止文件被复制? - How do I use Python to prevent a file from being copied? Robocopy(或xcopy)从文件中读取? - Robocopy (or xcopy) read from file? 使用带有参数“/efsraw”的Window 2008 R2的Robocopy加密文件显示接口未知,加密文件夹无法复制到目标 - Robocopy encrypted file using Window 2008 R2 with parameter "/efsraw" show The interface is unknown and encrypted folder failed to copy over to target 检测正在将文件复制到文件夹中 - Detecting that files are being copied in a folder 使用Filename + Robocopy日志记录中的当前日期创建文件 - Create File with current Date in Filename + Robocopy logging RoboCopy 在通用文件路径中出错 - RoboCopy giving error in universal file path 在Windows命令中将两个文件合并为一个文件只会导致第一个文件被复制 - Combining two files into a single in windows command only result in the first file being copied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM