Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Greetings,
I am new to batch programming and need some expert help. Here is what I would like to do:
1. Check if an external USB HD is present. Shows up as "E:". If not there, post message and exit bat file.
2. Copy My Documents and all sub folders to a new directory on E which is named Backup on Todays Date (something like 4-15-2007).
3. Copy some selected folders like Favorites to the new folder on E.
3. Copy some specific files to the new folder on E:I think XCOPY is the right command to use based on a lot of reading, however, the rest is not clear to me.
Thanks in advance for your kind help!

The script below may be a starting point, try it then add the XCopy for files and folders you need to backup
@Echo Off
Echo.
If exist E:\ (
Echo. External USB HD ready for BackUp
) else (
Echo. No External USB HD detected & Goto :EOF)
Echo.
Set ToDay=%Date:~-4,4%-%Date:~-10,2%-%Date:~-7,2%
XCopy "C:\Documents and Settings\%UserName%\My Documents" E:\BackUp_%ToDay% /I /E /S
XCopy "C:\Documents and Settings\%UserName%\Favorites" E:\BackUp_%ToDay% /I /E /S
Set ToDay=
::END_OF_BATCHFor the ToDay date format I prefer YYYYMMDD as this is more suitable for a progressive storage.

How can this be modified to automatically backup to different folders based of name of the week, existing folders Monday-Saturday, based on the default windows date format?
Eddieduce

With batch scripts you can do *almost* everything, assuned it is worth of it.
Now NT batch language is lacking of builtin date/time mathematics, so relaying upon its raw arithmetics leads to cumbersome and unhandly code.
Last but not least, the date format is counry dependent and not directly suitable to be part of folders/filenames (the / separator is a forbidden character).
So stated what you want can be achieved, but I don't follow you on that lane, more I warn you to go on: be sure, I know what I'm speaking about.

![]() |
Comapring DLL/executable ...
|
Need VB Script help
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |