1

I'm using the batch file below:

@echo
 for /f "tokens=1-3 delims=/ " %%a in ('date /t') do (
  set _date=%%a%%b%%c
  )
robocopy D:\a D:\b /mir /mot:1 /log:"d:\logs\%_date%.txt"
exit

But it creates a single file.

I'd want robocopy logs of each day in a separate text file , named with the current date.

Farrukh Khan
  • 31
  • 1
  • 2
  • 4

2 Answers2

2

This would be a lot easier if you did it in powershell.

$date = Get-Date -format yyyyMd

robocopy D:\a D:\b /mir /mot:1 /log:$date.txt

Is there a reason you can't use powershell?

Katherine Villyard
  • 18,510
  • 4
  • 36
  • 59
  • no i can use powershell as well. replication is real time and i want logs file , which gives me information of one day in one file. – Farrukh Khan Oct 29 '17 at 09:49
1

I'm trying to accomplish the same thing, but using a Robocopy job file (*.rcj). To solve the original, simply add at the command line /LOG+:%DATE:~10,4%%DATE:~7,2%%DATE:4,2%.txt - this will give you a 20191023.txt output and change as the date changes. Doesn't work on .RCJ files though.

Alexander Tolkachev
  • 4,513
  • 3
  • 14
  • 23
Todd S
  • 11
  • 1
  • Using %DATE% interactively in a command prompt worked, but not when running Robocopy in a scheduled task. I changed the scheduled task action to 'cmd /c robocopy ...', and then it worked. It's about accessing environment variables I think. Perhaps something to test with the .RCJ? – Bert Van Landeghem Jun 24 '22 at 15:11