1.

Solve : Appending modification timestamp to a filename?

Answer»

I've been asked to write a batch file to do the following: ftp a LOG file from a unix server to a Windows machine and append the modification date and time of that file to its name. These ftp'd files will always be called log1, log2 etc up to log5.
The Windows systems used will be 2K and XP. I have almost no programming skills, and whilst I can write the ftp part of this, I cannot get ANYWHERE with the file rename. Needless to say, I would be extremely happy with any help. Thanks, PaulThis is a matter of creating a token that can be appended to your file label:

Code: [Select]@echo off
for /f "tokens=2-4 delims=/ " %%i in ("%date%") do (
set mm=%%i
set dd=%%J
set yy=%%k
)
set today=%yy%_%mm%_%dd%

You may have to make adjustments. Date is assumed to be mm-dd-yyyy. Once %today% is defined you can use it as you wish (log5_%today%). Use the same technique if your requirements include the time.

8-)

In the future please do a Search on Computer HOPE. Most of this response was copied from a previous post made only a week ago.



Discussion

No Comment Found