1.

Solve : MS-DOS datetime append to a file?

Answer»

Hi All

I am a NOVICE in MS-Dos programming, but I have to use this in SUBMITTING this to one of our existing systems. I need to append the current datetime to a fixed file name before sending to our trading partner.

SET DIRECT="C:\Program Files\cdnt\Direct.exe"

SET R=%RANDOM%%RANDOM%

:: "TEMP1" holds the Process and Queries to be submitted to the CLI.
SET TEMP1="%R%TEMP1.TMP"

:: "PROCDATE" and "PROCTIME" hold the date and time this batch file is run.
:: This date and time is used when QUERYING the Process Monitor and
:: the Select STATISTICS from the CLI.
SET PROCDATE=%DATE%
SET PROCTIME=%TIME%

:: "TODAY" holds the date in the format EXPECTED by the CLI.
FOR /F "TOKENS=2-4 DELIMS=/ " %%i IN ( "%PROCDATE%" ) DO SET TODAY=%%i%%j%%k

:: "RUNTIME" holds the time in the format expected by the CLI.
FOR /F "TOKENS=1-4 DELIMS=:." %%i IN ( "%PROCTIME%" ) DO SET RUNTIME=%%i%%j%%k%%l


In the above whenever the time is less than 10am, the program is not working. Is there anyway we can add a 0 whenever the time is less than 10. Please help




Discussion

No Comment Found