Solved

Robocopy Log File

Posted on 2012-03-20
13
861 Views
Last Modified: 2012-03-28
Is there a way to log ONLY the files that are copied from source to destination; that is new files only.
0
Comment
Question by:lionelmm
13 Comments
 
LVL 10

Accepted Solution

by:
ReneGe earned 250 total points
ID: 37745656
Robocopy "%FolderSource%" "%FolderDestin%" *.* /E /NP /XO /copyall /XF "desktop.ini" "Thumbs.db" ".~*.*" "*.*#" "~*.*" "*.swp" "*.dmp" "*.tmp" "pagefile.sys" "hiberfil.sys" /XD "TEMP" >>LogFile.txt

Robocopy "%FolderSource%" "%FolderDestin%" *.* /E /NP /XO /copyall /XF "desktop.ini" "Thumbs.db" ".~*.*" "*.*#" "~*.*" "*.swp" "*.dmp" "*.tmp" "pagefile.sys" "hiberfil.sys" /XD "TEMP"  | FINDSTR -i "new file" >>LogFile.txt

Also, to see the loging options, type:
robocopy /? | findstr -i log
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37746430
No need to use Robocopy....

Use XCOPY which is part of DOS...

    XCOPY "%source%" "%destination%" /c /d /y

This will copy newer files from the source folder to the destination folder. If you want to copy files in subfolders too then you need to add '/e' to the command.
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 37746616
one small additon:

XCOPY "%source%" "%destination%" /c /d /y >copiedfiles.txt
0
 
LVL 24

Author Comment

by:lionelmm
ID: 37746634
problem with xcopy is that it will fail when you copy files with long directory structures so that is not an option--thanks anyway. used to be all I used until it started to fail.
0
 
LVL 24

Author Comment

by:lionelmm
ID: 37746653
ReneGe
thanks for the suggestions but unfortunately I knew all that before but thanks. What I was asking is if one of the log options was to log only the new files. I have been unable to find that myself so I was hoping someone would know a hidden or know switch to the logging options. As you noted I could add a line to my batch file that can go through a log file and extract based on "new file" but I was hoping for a one-step process, a logging option part of robocopy.
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37746958
Oops! I did forget to redirect the output.... which is why I posted in the first place however, because I tested XCOPYs command options, I lost sight of the main objective - silly, but it happens to the  best of us! lol

Thank you for pointing that out.

    XCOPY "%source%" "%destination%" /c /d /y >>"%outputfile%"

Notice I included '>>' instead of just '>' to APPEND the output rather than replace it, but you can use either.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 51

Expert Comment

by:Bill Prew
ID: 37750545
If you want to copy all files but just log the new ones, then I think Rene's approach is all you have.  No hidden options in ROBOCOPY to do it by itself.

~bp
0
 
LVL 24

Author Closing Comment

by:lionelmm
ID: 37771115
No Solution but thanks for the effort and time.
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37771199
??? No solution ???

How about:

    XCOPY "%source%" "%destination%" /c /d /y >>logfile.txt

Example:

    XCOPY "c:\folder1\*.*" "c:\folder2\" /c /d /y >>logfile.txt

Will copy all newer files from c:\folder1\ to c:\folder2\ and add a list of copied files to logfile.txt.
0
 
LVL 24

Author Comment

by:lionelmm
ID: 37771456
When you first responded I did not say anything because I felt there was no need to, in the hope that someone else would come up with a solution however your response now requires that I respond more directly. Did you read my Question? What does the Title of my question say? As a reminder here it is again "Robocopy Log File". To give me an xcopy solution -- you even say No need to use Robocopy.... Use XCOPY which is part of DOS...ignores my question and basically says "don't use what you are--use what I tell you to." I was not asking for an xcopy solution, and I told you (see above) "problem with xcopy is that it will fail when you copy files with long directory structures so that is not an option" Still, after all that, you still want to argue. You give a solution which is not about the app I am asked about and then you argue with me? Surely the asker, that's me, should be able to decide what the answer to the question is. Come on man. I could have simply deleted this question because there is NO ANSWER, but I still rewarded points to the one person who responded with a solution of some sort about my question which was about robocopy.
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37771886
Apologies.

You're quite right, I overlooked the fact you wanted a solution for ROBOCOPY.

I didn't know you had issues with long pathnames.

I must admit, I didn't read every reply.

Sorry there was no solution on this occasion.

Out of curiosity, does the following work for you?

    robocopy "source_path" "destination_path" *.* /LOG+:"logfile.txt"

Other options can be added to filter the logging of information. See:

    http://ss64.com/nt/robocopy.html
0
 
LVL 24

Author Comment

by:lionelmm
ID: 37776177
The issue is a way to get a log file with only NEW files copied in it
0
 
LVL 11

Expert Comment

by:paultomasi
ID: 37776289
How do you define 'NEW files'?

    - Files that don't already exist in the destination folder

    - Files that do already exist but are older than the source files

    - Or both of the above.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Ever notice how you can't use a new drive in Windows without having Windows assigning a Disk Signature?  Ever have a signature collision problem (especially with Virtual Machines?)  This article is intended to help you understand what's going on and…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now