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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NVITEnd-user supportCommented:
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
NVITEnd-user supportCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

namergSystems AdministratorAuthor Commented:
ohh ok, let me see
0
namergSystems AdministratorAuthor Commented:
Thank You sir
0
NVITEnd-user supportCommented:
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
NVITEnd-user supportCommented:
You're welcome. Have a nice day.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.