Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

writing a batch file to check the date

Thread Tools
 
Search this Thread
 
Old 22 July 2003, 12:40 PM
  #1  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 22 July 2003, 01:02 PM
  #2  
nigelward
Scooby Regular
 
nigelward's Avatar
 
Join Date: Oct 2001
Posts: 831
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 22 July 2003, 02:04 PM
  #3  
paula_k
Scooby Newbie
 
paula_k's Avatar
 
Join Date: Jul 2003
Posts: 7
Likes: 0
Received 0 Likes on 0 Posts
Post

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

Old 22 July 2003, 02:36 PM
  #4  
paula_k
Scooby Newbie
 
paula_k's Avatar
 
Join Date: Jul 2003
Posts: 7
Likes: 0
Received 0 Likes on 0 Posts
Post

is it possible to incorporate winzip into batch commands ?

I need to compress some files before moving them to a destination folder
Old 22 July 2003, 02:41 PM
  #5  
JackClark
Scooby Senior
 
JackClark's Avatar
 
Join Date: Dec 2000
Location: Overdosed on LCD
Posts: 20,852
Received 51 Likes on 34 Posts
Post

PKZip has a command line interface.

[Edited by JackClark - 7/22/2003 2:42:23 PM]
Old 22 July 2003, 03:23 PM
  #6  
paula_k
Scooby Newbie
 
paula_k's Avatar
 
Join Date: Jul 2003
Posts: 7
Likes: 0
Received 0 Likes on 0 Posts
Post

cheers jack
Old 22 July 2003, 04:25 PM
  #7  
DJ Dunk
Moderator
Support Scoobynet!
iTrader: (5)
 
DJ Dunk's Avatar
 
Join Date: Nov 2001
Location: Not all those who wander are lost
Posts: 17,863
Received 0 Likes on 0 Posts
Post

DazV = paula_k ?

Forgot to change back after the weekend Daz ?
Old 22 July 2003, 05:07 PM
  #8  
rik1471
Scooby Regular
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

B U S T E D !
Old 22 July 2003, 08:51 PM
  #9  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

its a fair cop, I masquerade as a woman by day

by night, a sexually deviant necrophiliac with a penchant for beastiality

...or am I just flogging a dead horse ?

Old 22 July 2003, 09:04 PM
  #10  
rik1471
Scooby Regular
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

lol
Old 22 July 2003, 10:30 PM
  #11  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

anyone know if its possible to use command lines to control a cd rewriter ?

eg.
xcopy to d: (where d: is the rewriter) ?

Old 23 July 2003, 08:13 AM
  #12  
nigelward
Scooby Regular
 
nigelward's Avatar
 
Join Date: Oct 2001
Posts: 831
Likes: 0
Received 0 Likes on 0 Posts
Post

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...
Oops, guess there must be some differences in the FOR command on NT4 and W2K, glad you worked it out.

Can't believe I missed the terminating % on the today environment variable as well.

Sheila
Old 23 July 2003, 08:33 AM
  #13  
rik1471
Scooby Regular
 
rik1471's Avatar
 
Join Date: Nov 2001
Posts: 4,788
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 23 July 2003, 05:08 PM
  #14  
DazV
Scooby Regular
Thread Starter
 
DazV's Avatar
 
Join Date: Jun 2000
Posts: 3,783
Likes: 0
Received 0 Likes on 0 Posts
Post

cool
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
Frizzle-Dee
Essex Subaru Owners Club
13
09 March 2019 07:35 PM
thunder8
General Technical
0
01 October 2015 09:13 PM
yabbadoo4
ScoobyNet General
11
30 September 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM



Quick Reply: writing a batch file to check the date



All times are GMT +1. The time now is 12:16 PM.