Computing.Net > Forums > Programming > Backup USB

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Backup USB

Reply to Message Icon

Name: Dosnotes
Date: June 10, 2009 at 16:03:24 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

Im wanting to back up a usb stick periodically & automatically.

Ive created the batch file with the commands;

MD C:\k\ALL_FILES_FROM_MY_USB_@%Date:~-10,2%%Date:~-7,2%%Date:~-4,4%@%time:~0,2%.%time:~3,2%
xcopy e:\*.* /S /E /v C:\k\ALL_FILES_FROM_MY_USB_@%Date:~-10,2%%Date:~-7,2%%Date:~-4,4%@%time:~0,2%.%time:~3,2%

and have set this to run via scheduled tasks in xp every hour.

This works fine during the day though each morning instead of creating a folder named with the current date and time (eg. ALL_FILES_FROM_MY_USB_@11062009@10.28); it creates 2 folders; one with the date and one with the time; eg

ALL_FILES_FROM_MY_USB_@11062009@

and also

10.28

and therefore doesnt backup the usb.

When I recreate the batch file it works fine.

Anyone know what the prob is or if theres another way to script this.

thanks



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 10, 2009 at 17:56:35 Pacific
Reply:

First guess is before 10:00 you're getting a single digit hour which is throwing a curve ball to the script.


=====================================
If at first you don't succeed, you're about average.

M2


0

Response Number 2
Name: Dosnotes
Date: June 15, 2009 at 20:43:39 Pacific
Reply:

yeah looks as though thats the issue, it just doesnt work for the single digit hours. anyone know how 2 fix this


0

Response Number 3
Name: Mechanix2Go
Date: June 15, 2009 at 23:37:30 Pacific
Reply:

Use this bat to set date vars.

=============================
::== YMD8.bat

@echo off > d.d

>> d.d echo E 0100 B4 2A CD 21 B4 4C CD 21
>> d.d echo N DAY.COM
>> d.d echo RCX
>> d.d echo 8
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 F0 B4 4C CD 21
>> d.d echo N MONTH.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 89 C8 B4 4C CD 21
>> d.d echo N YEAR.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo E 0100 B4 2A CD 21 88 D0 B4 4C CD 21
>> d.d echo N DAT.COM
>> d.d echo RCX
>> d.d echo A
>> d.d echo W
>> d.d echo Q

debug < d.d > nul
del d.d

dat
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set dat=0%%a
for %%a in ( 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31) do if errorlevel %%a set dat=%%a
echo Date %dat%

day
if errorlevel 0 set day=Sunday
if errorlevel 1 set day=Monday
if errorlevel 2 set day=Tuesday
if errorlevel 3 set day=Wednesday
if errorlevel 4 set day=Thursday
if errorlevel 5 set day=Friday
if errorlevel 6 set day=Saturday
echo Day %day%

month
for %%a in (1 2 3 4 5 6 7 8 9 ) do if errorlevel %%a set month=0%%a
for %%a in ( 10 11 12) do if errorlevel %%a set month=%%a
echo Month %month%

year
if errorlevel 215 set Year=2007
if errorlevel 216 set Year=2008
if errorlevel 217 set Year=2009
if errorlevel 218 set Year=2010
echo Year %Year%

del day.com
del month.com
del year.com
del dat.com
::== DONE


=====================================
If at first you don't succeed, you're about average.

M2


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Backup USB

Backup using xcopy - date in folder www.computing.net/answers/programming/backup-using-xcopy-date-in-folder/16705.html

USB I/O Backup in DOS www.computing.net/answers/programming/usb-io-backup-in-dos-/17395.html

USB Events in VB6 www.computing.net/answers/programming/usb-events-in-vb6/14775.html