Automating the renaming of files.

Rodney

Distinguished
Mar 4, 2002
82
0
18,630
Archived from groups: microsoft.public.win2000.file_system (More info?)

I have a log file, ecommlog.log, that gets created daily at 6am and I would
like to rename the logfile to econlddmmyyyy.log. (I would like for the
ddmmyyyy to be that days date). Does anyone know of a script that can do this?

Thanks,
Rodney
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Assuming you are using W2K, the %date% variable is set by the OS.
Running "set /?" will give you lots of info.

Here's a start:

rem -- current date
set C_DATE=%DATE:~7,2%
rem -- current month
set C_MONTH=%DATE:~4,2%
rem -- four-digit year
set C_YEAR=%DATE:~-4%


You could write a batch file with something like:

rename ecommlog.log econl%C_DATE%%C_MONTH%%C_YEAR%

And schedule that batch file to run at the appropriate time.
-Sean

Rodney wrote:
> I have a log file, ecommlog.log, that gets created daily at 6am and I would
> like to rename the logfile to econlddmmyyyy.log. (I would like for the
> ddmmyyyy to be that days date). Does anyone know of a script that can do this?
>
> Thanks,
> Rodney
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

On Fri, 20 Aug 2004 09:57:03 -0700, Rodney <Rodney@discussions.microsoft.com>
wrote:

>I have a log file, ecommlog.log, that gets created daily at 6am and I would
>like to rename the logfile to econlddmmyyyy.log. (I would like for the
>ddmmyyyy to be that days date). Does anyone know of a script that can do this?
>
>Thanks,
>Rodney

use Univdate.bat from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com
to parse the date on any computer into its month, day, and year components.

call univdate
ren ecommlog.log econl%dd%%mm%%yy%.log
where the variable names are from the second line when you type:
date



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

Rodney

Distinguished
Mar 4, 2002
82
0
18,630
Archived from groups: microsoft.public.win2000.file_system (More info?)

Thank you Jerold. That did the trick!!! :)


"Jerold Schulman" wrote:

> On Fri, 20 Aug 2004 09:57:03 -0700, Rodney <Rodney@discussions.microsoft.com>
> wrote:
>
> >I have a log file, ecommlog.log, that gets created daily at 6am and I would
> >like to rename the logfile to econlddmmyyyy.log. (I would like for the
> >ddmmyyyy to be that days date). Does anyone know of a script that can do this?
> >
> >Thanks,
> >Rodney
>
> use Univdate.bat from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com
> to parse the date on any computer into its month, day, and year components.
>
> call univdate
> ren ecommlog.log econl%dd%%mm%%yy%.log
> where the variable names are from the second line when you type:
> date
>
>
>
> Jerold Schulman
> Windows: General MVP
> JSI, Inc.
> http://www.jsiinc.com
>
 
G

Guest

Guest
Archived from groups: microsoft.public.win2000.file_system (More info?)

Well, sure, use that mess. I guess it works. I'd hate to have to figure
out what it does, or how to debug it.

More than one way to skin a cat, I 'spose.

Jerold Schulman wrote:
> On Fri, 20 Aug 2004 09:57:03 -0700, Rodney <Rodney@discussions.microsoft.com>
> wrote:
>
>
>>I have a log file, ecommlog.log, that gets created daily at 6am and I would
>>like to rename the logfile to econlddmmyyyy.log. (I would like for the
>>ddmmyyyy to be that days date). Does anyone know of a script that can do this?
>>
>>Thanks,
>>Rodney
>
>
> use Univdate.bat from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com
> to parse the date on any computer into its month, day, and year components.
>
> call univdate
> ren ecommlog.log econl%dd%%mm%%yy%.log
> where the variable names are from the second line when you type:
> date
>
>
>
> Jerold Schulman
> Windows: General MVP
> JSI, Inc.
> http://www.jsiinc.com