writing a batch file to check the date
#1
haven't touched batch files in a long while, but knowing there's some server admins on here I was wondering if you could tell me if its possible to:
check todays date
if its a monday, copy folder x to destination z:/monday
if its tuesday, copy folder x to detination z:/tuesday
etc...
Thanks in advance
PS: OS = Win2k server
check todays date
if its a monday, copy folder x to destination z:/monday
if its tuesday, copy folder x to detination z:/tuesday
etc...
Thanks in advance
PS: OS = Win2k server
#2
A possible solution:
FOR /F "tokens=1" %i in ('DATE /T') do set today=%i
IF NOT "%today"=="Mon" GOTO next
copy x to y:\monday
GOTO the_end
:next
IF NOT "%today"=="Tue" GOTO next
copy x to y:\tuesday
GOTO the_end
..and so on.
FOR /F "tokens=1" %i in ('DATE /T') do set today=%i
IF NOT "%today"=="Mon" GOTO next
copy x to y:\monday
GOTO the_end
:next
IF NOT "%today"=="Tue" GOTO next
copy x to y:\tuesday
GOTO the_end
..and so on.
#3
Hi, thanks for that. I couldn't get your code to work so I had a look at the FOR command and made the following changes...
FOR /F "tokens=1" %%i in ('DATE /T') do set today=%%i
IF NOT "%today%"=="Mon" GOTO tuesday
copy "file.txt" monday
GOTO the_end
:tuesday
IF NOT "%today%"=="Tue" GOTO wednesday
copy "file.txt" tuesday
GOTO the_end
:wednesday
:the_end
thnaks mate,
-DV
FOR /F "tokens=1" %%i in ('DATE /T') do set today=%%i
IF NOT "%today%"=="Mon" GOTO tuesday
copy "file.txt" monday
GOTO the_end
:tuesday
IF NOT "%today%"=="Tue" GOTO wednesday
copy "file.txt" tuesday
GOTO the_end
:wednesday
:the_end
thnaks mate,
-DV
Trending Topics
#12
Hi, thanks for that. I couldn't get your code to work so I had a look at the FOR command and made the following changes...
Can't believe I missed the terminating % on the today environment variable as well.
Sheila
#13
http://rikwakefield.com/software/createcd.zip
CreateCD [options] <FILESPEC>[<FILESPEC>]...
options - one or more of the following:
-e[rase] - Erase disk before writing
-f[ullerase] - Erase disk and quit. This is 'full" erase that takes quite some time
-nologo - Do not display logo string
-r[ecorder]:<LETTER> - Use recorder <LETTER>
-s[peed]:<NUMBER> - Use recording speed <NUMBER>
-v[erbose] - Produce more output
-info - Print recorder/disk information and exit
-eject - Eject disk after writing
-l[abel]:<VOLUME label> - Set volume label. Default is today's date
-i[mage]:<FILESPEC> - Make disk bootable using image <FILESPEC>. <FILESPEC>should be an image of a bootable floppy
Example: CreateCD -r:e -i:bootflpW98.img C:\Data\*.*
Rik
CreateCD [options] <FILESPEC>[<FILESPEC>]...
options - one or more of the following:
-e[rase] - Erase disk before writing
-f[ullerase] - Erase disk and quit. This is 'full" erase that takes quite some time
-nologo - Do not display logo string
-r[ecorder]:<LETTER> - Use recorder <LETTER>
-s[peed]:<NUMBER> - Use recording speed <NUMBER>
-v[erbose] - Produce more output
-info - Print recorder/disk information and exit
-eject - Eject disk after writing
-l[abel]:<VOLUME label> - Set volume label. Default is today's date
-i[mage]:<FILESPEC> - Make disk bootable using image <FILESPEC>. <FILESPEC>should be an image of a bootable floppy
Example: CreateCD -r:e -i:bootflpW98.img C:\Data\*.*
Rik
Thread
Thread Starter
Forum
Replies
Last Post