need help with date

  • Thread starter Thread starter ajmiester
  • Start date Start date
A

ajmiester

Hi

I have a script which renames a file abc.txt to abc.txt.yyyymmdd where
dd is today's date. When the process runs on Friday the date attached to the
file should reflect Monday's date i.e.if Friday's date is 20050805 then the
file name should have abc.txt.20050808. The tricky part is when the date
falls at the end of the month. Any suggestions

Aj
 
Hi

I have a script which renames a file abc.txt to abc.txt.yyyymmdd where
dd is today's date. When the process runs on Friday the date attached to the
file should reflect Monday's date i.e.if Friday's date is 20050805 then the
file name should have abc.txt.20050808. The tricky part is when the date
falls at the end of the month. Any suggestions

It's probably easiest to hand the task to WSH (Windows Script Host) with
a transient VBS file (WSH is installed by default in Windows 2000/XP).

This shows how to generate a UseDate variable that is today (YYYYMMDD)
if the day is not Friday, and the next Monday's date if today is Friday. Note
that any name generated on Friday will therefore conflict with the name
generated next Monday, making this seem a strange request.

Lines that don't begin with two spaces have wrapped accidentally
====Begin cut-and-paste (omit this line)
@ECHO OFF
SETLOCAL
ECHO/d=DateAdd("d",-3*(Weekday(now)=6),now)>_TEMP.VBS
ECHO/d=Year(d) ^& Right("0" ^& Month(d),2) ^& Right("0" ^& Day(d),2)>>_TEMP.VBS
ECHO/WScript.Echo "SET UseDate=" ^& d>>_TEMP.VBS
cscript//nologo _TEMP.VBS>_TEMP.BAT
CALL _TEMP.BAT
DEL _TEMP.BAT _TEMP.VBS
ECHO. Date to use in Rename is: %UseDate%

====End cut-and-paste (omit this line)
Simulated Win2000 for study/demo use. Cut-and-paste as Batch text file.
Batch file troubleshooting: http://www.allenware.com/find?UsualSuspects
 
ajmiester said:
Hi

I have a script which renames a file abc.txt to abc.txt.yyyymmdd where
dd is today's date. When the process runs on Friday the date attached to
the
file should reflect Monday's date i.e.if Friday's date is 20050805 then
the
file name should have abc.txt.20050808. The tricky part is when the date
falls at the end of the month. Any suggestions

Aj

Not nearly enough info, I believe.

What happens on other days? On Monday, it would appear that you would
attempt to rename abc.txt to a name that already exists - it was set up last
Friday as abc.txt.mondaysdate

Does the job get run at weekends? What happens if Monday or Friday are
public holidays?

If we have an overview of what your purpose is, rateher than a panoramic
view of the minutae, we might be able to make more usable suggestions.

HTH

....Bill
 
Back
Top