Computing.Net > Forums > Programming > System date in file names

System date in file names

Reply to Message Icon

Original Message
Name: Nearlynormal
Date: September 26, 2004 at 15:50:32 Pacific
Subject: System date in file names
OS: Win2KPro
CPU/Ram: PIII1.4, 256MB
Comment:

Our office network uses Win2K Server and our PCs use Win2KPro. We are using a program called RealPopup for text messaging between PCs. RealPopup allows each PC to log all messages in a plain-text file with a .log extension. I would like to save each day's messages in a separate file. I am trying to figure out how to write a batch file that would run every evening that would rename the logfile from, e.g., Logfile.log to a file named with the system date, i.e., mmddyy.log, and then would create a new, empty Logfile.log file for the next day.


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: September 27, 2004 at 00:03:20 Pacific
Reply: (edit)

Hi,

ren Logfile.log "%DATE%".log

@echo off > Logfile.log

::-----
Your mileage may vary, according to the way your date is formatted (in control panel).

If it has a colon or slash, it won't fly. Commas and dots aren't so wonderful, either.

HTH



Report Offensive Follow Up For Removal

Response Number 2
Name: FishMonger
Date: September 27, 2004 at 12:07:41 Pacific
Reply: (edit)

You can build-up/re-arrange the output of the date command.

C:\>echo %date%
Mon 09/27/2004

C:\>echo %date:~4,2%%date:~7,2%%date:~12,2%.log
092704.log


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: System date in file names

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




Have you ever used OpenOffice?

Yes, as my main suite.
Yes, occationally.
Yes, but only once.
No, never.


View Results

Poll Finishes In 5 Days.
Discuss in The Lounge