1

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.

Ross Ridge
  • 38,414
  • 7
  • 81
  • 112
Christopher Moore
  • 49
  • 2
  • 2
  • 11

1 Answers1

1

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 %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.

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. Or you can get use of these 5 options on robocopy:

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?

Note that % progress is shown per file on robocopy but not per directory.

Community
  • 1
  • 1
Felype
  • 3,087
  • 2
  • 25
  • 36
  • Thank you so much for taking the time to explain that all to me. Sooo - it sounds like it cant be done? Or, at least not the way i was intending? – Christopher Moore Mar 31 '15 at 16:50
  • @ChristopherMoore indeed, i've researched here and, can be done, but not through robocopy. Maybe with for loop iterating through several dir with /s /b results or windows powershell, then you'd have to count how many files needs to be copied and the amount of files already copied, your % is copiedFiles * 100 / totalFiles; This method can get quite extensive and time spending to get done. You can filter the output of a program with | findstr (in front of the command) but, this method will wait until robocopy is done running before posting the output. – Felype Mar 31 '15 at 17:04
  • Thank you both for your time. It sounds like it would be more of a pain than it is worth, but i was just curious and thought it would be cool. – Christopher Moore Mar 31 '15 at 17:07
  • Ooh, wait! What if it displayed "Now backing up (FOLDER NAME)" and did display the file it was copying but then cleared said file from the screen once said file is finished copying and replaced that line with the next file? That would be just as good for my purposes. – Christopher Moore Mar 31 '15 at 17:29
  • You'd have to filter robocopy output, to filter its output you'd have to use | findstr and, by the way DOS works it would wait for the entire robocopy process to finish before filtering, this would not be a 'real time' percentage show, as I said, you could write something brand new or deal with robocopy way. check Robocopy /? in the last few lines for "output" flags you can define. – Felype Apr 01 '15 at 14:30