Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Would like to backup(xcopy) files to a different directory for each day of the week. Batch file needs to determine day(Sunday-Saturday)automatically, and then copy data files from the application working directory to the appropriate day's backup directory.

The first hump to get over is getting the DAY into a variable for use by the backup bat.
This will get DAY, DATE and TIME into varibles.
:: DtimeDOS.bat
@echo offecho.|date>datevar.bat
echo.|time>timevar.batecho set DATEvar=%%4>current.ba
call datevarecho set DAYvar=%%3>current.ba
call datevarecho set TIMEvar=%%3>current.ba
call timevar
:: doneNote that it may need to be tailored becase the output of the DATE & TIME will vary according to version, language, codepage etc.
Once you get that hammered out:
cd c:\appdata
xcopy . c:\DAYvar\
If at first you don't succeed, you're about average.M2

M2,
Many thanks for the help. Looks like that will get the date up in a numerical format ok. Any ideas on how to translate that to day of the week, ie; Sunday, Monday, etc. I want to have seven backup directories so I can have a rolling week of backups?
EGB

I saw this site the other day - he uses a program called XSET to simplify the process - seems to be what you're seeking.
If the xset link isn't working, try FileLibrary

Hi
Put the Weekday.com code into a text file.
Put a blank line after the last Q.
Save it as Weekday.scr then enter this
on the command line.
debug < Weekday.scr
this creates Weekday.comCreate the second batch file and modify
the "echo it's" to the code required for
the day of the week.
---------------------------
N WEEKDAY.COM
A 100
MOV AH,2A
INT 21
MOV AH,4C
INT 21R CX
8
W
Q--------------------------
@echo off
weekday.com
if errorlevel 0 if not errorlevel 1 goto Sunday
if errorlevel 1 if not errorlevel 2 goto Monday
if errorlevel 2 if not errorlevel 3 goto Tuesday
if errorlevel 3 if not errorlevel 4 goto Wednesday
if errorlevel 4 if not errorlevel 5 goto Thursday
if errorlevel 5 if not errorlevel 6 goto Friday
if errorlevel 6 goto Saturday:Sunday
echo It's Sunday
goto Done
:Monday
echo It's Monday
goto Done
:Tuesday
echo It's Tuesday
goto Done
:Wednesday
echo It's Wednesday
goto Done
:Thursday
echo It's Thursday
goto Done
:Friday
echo It's Friday
goto Done
:Saturday
echo It's Saturday
:Done

As per #1:
"Note that it may need to be tailored becase the output of the DATE & TIME will vary according to version, language, codepage etc."
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

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