1.

Solve : bat file processing a file with a date as part of the file name?

Answer»

I have a file aaa-bbb_yyyymmdd - yyyymmdd = current date. The file is really a logfile, created new each day at 12 AM with the current date as part of the file name.

I am attempting to setup an automated process to access the file which has a moving name each day. The process will use a BAT with imbedded DOS commands
e.g. findstr etc. to create a file (static filename) which will be used by a secondary process.

How or what can I use to concatenate the stem filename aaa-bbb and the current date… I have displayed the %DATE% variable in the BAT file and it
is displayed as yyyy/mm/dd which is not much use to me….

I don't have any experience with C and very little Perl experience… I was hoping there might be something in DOS itself..
Quote

I have displayed the %DATE% variable in the BAT file and it
is displayed as yyyy/mm/dd which is not much use to me….

You can use this notation for the current date: %date:/=% to strip out the slashes.

Code: [Select]aaa-bbb_%date:/=%

Good LUCK. Quote from: SIDEWINDER on September 25, 2008, 06:20:11 PM
You can use this notation for the current date: %date:/=% to strip out the slashes.

The notation WORKS like this

%string:cat=dog%

That MEANS: in %string% remove every occurrence of "cat" and put "dog" in its place. In the string variable whose name appears between the first percent sign and the colon, replace whatever is between the colon and the equals sign with whatever is between the equals sign and the right hand side percent sign. So %date:/=% replaces / with nothing, and %date:/=-% replaces / with a - (minus sign or hyphen).

Many thanks.. that helped me a lot...
Now, to ramp my issues up a notch... is there something available for date manipulation? E.G. I have a file aaa-bbb-20080930 which represents a file created on 20080930. I execute a process on 20081001 which needs the prior day's file which is aaa-bbb-20080930 . If I merely SUBTRACT 1 from today's date I'm not ending up with what I want...


Discussion

No Comment Found