Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Date and time in batch file  (Read 3088 times)

0 Members and 1 Guest are viewing this topic.

jussi

    Topic Starter


    Starter

    Date and time in batch file
    « on: March 03, 2009, 12:12:01 AM »
    I have a small problem: I use a batch file that runs an automatic backup of a software and fills a log-file of backup process. At the moment I use date /t and time /t commands with a pre-typed strings of text to monitor different sub processes in the backup, but it writes the time and string on separate row whereas I would like them on the same row, like this:

    mon 02.03.2009
    21:00 Process started
    21:01 Backup 1 finished
    21:08 Backup 2 finished
    21:10 Backup finished succesfully

    The commands that I have been using are obviously the reason:
    time /t >> %LogFilePath%\Backup.log
    echo Backup finished succesfully >> %LogFilePath%\Backup.log

    Is there any command I can make it write the strings on the same row as the time?

    -Jussi

     

    oldun

    • Guest
    Re: Date and time in batch file
    « Reply #1 on: March 03, 2009, 04:31:21 AM »
    You might try something like this:

    Code: [Select]
    Echo %time:~0,5% Backup finished successfully >>%LogFilePath%\Backup.log