I have multiple folders containing assets (each folder has subfolders containing these assets .mp3, .txt, .png, etc). I want to copy all this assets along with the subfolder to a single location/folder. I was able to successfully run a robocopy command to achieve copying of assets along with subfolders from one folder to another folder:

robocopy source target /s

I will be running a scheduler once daily to copy the assets. Also I wanted to store the name of all the copied assets in a log file. The name of the log file should be in the form of


for example if the today's date is 20th Oct 2015... the name of the log file should be:


The next day i.e. 21st Oct 2015, it should be:


This log file should contain the name of all the copied assets on 20th Oct 2015, 21st Oct 2015 and so on. I created a batch command (thanks to @DavidPostill) to create a log as follows:

@echo off
for /f "tokens=1-3 delims=/ " %%a in ('date /t') do (
set _date=%%a%%b%%c
echo robocopy source target /log:D:\ABC\log%_date%.txt

This creates a log with the name "logTue2010.txt" (i.e. logdayddmm format). Problem:

  1. Where does this log file gets stored? To make visible this log file, I have to write a separate command everyday as follows:

robocopy source target /log:D:\ABC\logWed1021.txt /tee /s

  1. How do I ensure that a separate copy of log is obtained each day?
  2. Also with the current command, the log file contains the entire output displayed on the cmd window. I just want it to contain the name of the asset with its extension.

EDIT: As per @JosefZ I edited my batch file as follows:

@echo off
for /f "tokens=2 delims==" %%G in ('wmic OS get LocalDateTime /value') do set "_date=%%G"
set "_date="%_date:~0,8%
echo robocopy source target /log:D:\ABC\log\log_%_date%.txt
robocopy source target /log:D:\ABC\log\log_%_date%.txt /S

I received the following output:

robocopy source target /log:D:\ABC\log\log_.txt
Log File : D:\ABC\log\log_.txt

Get YYYYMMDD-formatted date independently of locale and regional settings using for /F loop against wmic (Windows Management Instrumentation Command) and environment variable substring:

@echo off
for /f "tokens=2 delims==" %%G in ('wmic OS get LocalDateTime /value') do set "_date=%%G"
set "_date=%_date:~0,8%"

There are more robocopy logging options:

            /L : List only - don’t copy, timestamp or delete any files.
           /NP : No Progress - don’t display % copied.
      /unicode : Display the status output as Unicode text.   #
     /LOG:file : Output status to LOG file (overwrite existing log).
  /UNILOG:file : Output status to Unicode Log file (overwrite)
    /LOG+:file : Output status to LOG file (append to existing log).
 /UNILOG+:file : Output status to Unicode Log file (append)
           /TS : Include Source file Time Stamps in the output.
           /FP : Include Full Pathname of files in the output.
           /NS : No Size - don’t log file sizes.
           /NC : No Class - don’t log file classes.
          /NFL : No File List - don’t log file names.
          /NDL : No Directory List - don’t log directory names.
          /TEE : Output to console window, as well as the log file.
          /NJH : No Job Header.
          /NJS : No Job Summary.
robocopy B Bcopy /log:D:\ABC\log\log_%_date%.txt /S /NP /NDL /NJH /NJS /NS /NC 

Above command (note /NP /NDL /NJH /NJS /NS /NC switches) will suppress almost all except (full-qualified) file names in robocopy output. However, file names are indented with some Tab and Space characters. Next code snippet should make output as desired:

>D:\ABC\log\log_%_date%.txt (
for /f "tokens=*" %%G in ('
    robocopy B Bcopy /S /NP /NDL /NJH /NJS /NS /NC
  ') do echo(%%G

For > explanation, see redirection. And the log file gets stored in specified folder (D:\ABC\log\); to ensure this, try

type D:\ABC\log\log_%_date%.txt
  • do I have to replace "/value" with something? – Yash Saraiya Oct 21 '15 at 7:28
  • @YashSaraiya no, the /value is a /FORMAT switch moniker. wmic OS get /VALUE is the same as wmic OS get /FORMAT:"C:\Windows\System32\wbem\textvaluelist.xsl". Note fully qualified filename in last command; /FORMAT:textvaluelist.xsl should suffice – JosefZ Oct 21 '15 at 7:56
  • Did you see the "EDIT" in my question? Please check and give update – Yash Saraiya Oct 21 '15 at 8:28
  • @YashSaraiya Sorry, adjusted wrong set "_date="%_date:~0,8% to right set "_date=%_date:~0,8%", see position of double quotes. Accidental mistake of copy&paste – JosefZ Oct 21 '15 at 8:49
  • It is working fine now... But I have mentioned other issues too... like currently my log contains everything that is shown up in the cmd upon firing a command... I want only the name of the assets that are copied and not the entire summary of cmd – Yash Saraiya Oct 21 '15 at 8:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.