Robocopy Log File

Is there a way to log ONLY the files that are copied from source to destination; that is new files only.
LVL 26
Lionel MMSmall Business IT ConsultantAsked:
Who is Participating?
ReneGeConnect With a Mentor Commented:
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
Paul TomasiCommented:
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.
David Johnson, CD, MVPOwnerCommented:
one small additon:

XCOPY "%source%" "%destination%" /c /d /y >copiedfiles.txt
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Lionel MMSmall Business IT ConsultantAuthor Commented:
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.
Lionel MMSmall Business IT ConsultantAuthor Commented:
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.
Paul TomasiCommented:
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.
Bill PrewCommented:
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.

Lionel MMSmall Business IT ConsultantAuthor Commented:
No Solution but thanks for the effort and time.
Paul TomasiCommented:
??? No solution ???

How about:

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


    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.
Lionel MMSmall Business IT ConsultantAuthor Commented:
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.
Paul TomasiCommented:

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:
Lionel MMSmall Business IT ConsultantAuthor Commented:
The issue is a way to get a log file with only NEW files copied in it
Paul TomasiCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.