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:
- 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
- How do I ensure that a separate copy of log is obtained each day?
- 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 1: With the following batch command I was able to resolve the issue pertaining to log filename format:
@ECHO OFF for /f %%a in ('wmic os get LocalDateTime ^| findstr ^[0-9]') do (set ts=%%a) ECHO %ts:~0,8%_%ts:~8,4% echo robocopy ship shore /log:D:\HAL\log\log_%ts:~0,8%_%ts:~8,4%.txt robocopy Ship Shore /log:D:\HAL\log\log_%ts:~0,8%_%ts:~8,4%.txt /S
Also this batch command worked as well:
@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 ship shore /log:D:\HAL\log\log_%_date%.txt robocopy ship shore /log:D:\HAL\log\log_%_date%.txt /S
However other questions asked here is still unanswered.