How to read a .BAT file and Rocopy

Hello,

Can you help me in reading this .bat and robocopy execution ? Thanks for your help

md \\server\share\LogFile\%date:~-4,4%\%date:~-10,2%
md \\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%

robocopy /MOV /v /lev:0 /log+:\\server\share\LogFile\%date:~-4,4%\%date:~-10,2%\log-%date:~4,2%%date:~7,2%%date:~10,4%.txt "\\server\share" "\\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%" 

Open in new window

namergSystems AdministratorAsked:
Who is Participating?
 
NVITCommented:
Yes. the batch will run. But, you will just see what it would do, but not actually run.

Add a line at the bottom to pause the batch:
ECHO md \\server\share\LogFile\%date:~-4,4%\%date:~-10,2%
ECHO md \\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%

ECHO robocopy /MOV /v /lev:0 /log+:\\server\share\LogFile\%date:~-4,4%\%date:~-10,2%\log-%date:~4,2%%date:~7,2%%date:~10,4%.txt "\\server\share" "\\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%" 
pause

Open in new window

1
 
NVITCommented:
Put an ECHO in front of each line, which will help you see the actual values:

ECHO md \\server\share\LogFile\%date:~-4,4%\%date:~-10,2%
ECHO md \\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%

ECHO robocopy /MOV /v /lev:0 /log+:\\server\share\LogFile\%date:~-4,4%\%date:~-10,2%\log-%date:~4,2%%date:~7,2%%date:~10,4%.txt "\\server\share" "\\server.lcl\files\Reports\Archive\%date:~-4,4%\%date:~-10,2%\%date:~-7,2%" 

Open in new window


Result:
md \\server\share\LogFile\2017\11
md \\server.lcl\files\Reports\Archive\2017\11\27
robocopy /MOV /v /lev:0 /log+:\\server\share\LogFile\2017\11\log-11272017.txt "\\server\share" "\\server.lcl\files\Reports\Archive\2017\11\27"

Open in new window

0
 
namergSystems AdministratorAuthor Commented:
Hmm, if i do Echo the batch will be executed through..I would prefer to know what it does before pulling the trigger...
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
namergSystems AdministratorAuthor Commented:
ohh ok, let me see
0
 
namergSystems AdministratorAuthor Commented:
Thank You sir
0
 
NVITCommented:
md = Make directory
https://ss64.com/nt/md.html


Robocopy switches:
/MOV :MOVe files (delete from source after copying
/V : Produce Verbose output log, showing skipped files.
/lev:0 : Only copy the top 0 LEVels of the source tree.
/LOG+:file : Output status to LOG file (append to existing log)

https://ss64.com/nt/robocopy.html

To build confidence, it's good practice to test any batch on a test folder.
1
 
NVITCommented:
You're welcome. Have a nice day.
0
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.