Frage

I know this question was duplicated many time and I tried almost all of it but I still unable to append date and time to a .txt . Sorry if this question make you mad or anything.

Here is my code:

cd C:\Users\310152922\Desktop\Mohit Task\Lumi_FTP
java Lumi_FTP "C:\Users\310152922\Desktop\Mohit Task\Lumi_FTP\lumi_ftp_settings.ini" >"C:\test\Scriptlogs\log_DP.txt"

exit;

The question is is how can I append date and time to a "name" of a .txt Example (expecting output): log_DP_DATE_ TIME.txt (log_DP_03112014_1146.txt)

Thank you very much for viewing, comment and answer.

p.s I m newbie for programming languages

War es hilfreich?

Lösung

The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher.

The variable is in the log file name below:

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"

cd /d "C:\Users\310152922\Desktop\Mohit Task\Lumi_FTP"
java Lumi_FTP "C:\Users\310152922\Desktop\Mohit Task\Lumi_FTP\lumi_ftp_settings.ini" >"C:\test\Scriptlogs\log_DP_%fullstamp%.txt"
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top