Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ROBOCOPY HELP 2

Status
Not open for further replies.

Keyboy

Technical User
Aug 22, 2003
193
US
Greetings,

I have a written a Robocopy bat file to back up the files on my laptop to a portable USB connected drive. I had some issues with the date functions but got that straightened out. However the file is not doing what I thought. Here is the file:

@Echo Off
Echo.
Echo.
Echo You must run this file by right clicking and run as Administrator.
Echo If not you won't get all the files. Crtl C exits.
Echo.
Echo.
If exist E:\ (Echo. External USB HD ready for BackUp) else (Echo. No External USB HD detected & Goto :EOF)
Echo.
pause
Echo.


For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set ToDay=%%c-%%a-%%b)

Robocopy "C:\Users\%UserName%\Favorites" "E:\Joe_BackUp-%ToDay%\Favorites" /E /Z /XA:H /R:10 /W:20

Robocopy "C:\Users\%UserName%\Desktop" "E:\Joe_BackUp_%ToDay%\Desktop" *.bat /XA:H /R:10 /W:20

Robocopy "C:\Users\%UserName%\Documents" "E:\Joe_BackUp_%ToDay%\My Documents" /E /Z /XA:H /R:10 /W:20

Robocopy "C:\Users\%UserName%\AppData\Local\Microsoft\Windows Live Mail" "E:\Joe_BackUp_%ToDay%\Windows Mail" /E/Z /XA:H /R:10 /W:20

Robocopy "C:\Xnews_test 2006.06.28" "E:\Joe_BackUp_%ToDay%\XNEWS" /E /R:10 /W:20

Set ToDay=
::END_OF_BATCH
Echo.
Echo.
Echo. All Done
pause

Here is the issue. I was expecting that I would end up with one folder on the backup drive and that there would be these sub-folders: Favorites, Desktop, My Documents, Windows Live Mail, and XNEWS. What I end up with is two dated folders one contains Desktop, My Documents, Windows Live Mail, and XNEWS subfolders and the other contains Favorites subfolder.

Can someone help me to get all the copied files in their subfolders under one backup folder? I am afraid my staring at the bat file has not found anything obvious so there is something I don't understand about ROBOCOPY.

Thanks in advance for your help!
 
The devil is in the details my friend. Take a look at this line:
E:\Joe_BackUp-%ToDay%\Favorites" /E /Z /XA:H /R:10 /W:20

You have a hyphen instead of an underscore which is in the other lines. Try that first!!!!!!!!!!!!!!!

"Living tomorrow is everyone's sorrow.
Modern man's daydreams have turned into nightmares.
 
Thanks! Worked like a charm. Like I said I stared and stared and couldn't see that. I believe it came as I was typing and had the Caps key depressed too early for the 'B'.
 
I spent most of a weekend on a hardware issue / hard drive upgrade on a server because I couldn't see a bent pin, so I know how it goes.

"Living tomorrow is everyone's sorrow.
Modern man's daydreams have turned into nightmares.
 
The small things will get you every time. I know they get me every time. Typos in code and bent pins on hard drives, etc... I hate the small things. [bigglasses]

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top