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

Author Topic: date log  (Read 2330 times)

0 Members and 1 Guest are viewing this topic.

alecsillidan

    Topic Starter


    Beginner

    date log
    « on: July 11, 2010, 06:31:52 PM »
    Hi guys!
    I have a small little question, everytime I start my PC a batch file saves the date, time and username in a %date%.log but if overwrites the file when i restart.
    How can I make the batch save the next log in the same file in different line?
    We never had to cheat 'cause we already won!

    Helpmeh



      Guru

    • Roar.
    • Thanked: 123
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Familiar
    • OS: Windows 8
    Re: date log
    « Reply #1 on: July 11, 2010, 07:25:06 PM »
    Try this:

    @echo off
    if exist %date%.log (
    echo %time%---%username% >> %date%.log
    ) else (
    echo %time%---%username% > %date%.log
    )

    OR, you can just use the double >> signs and it will create a new file if required, or append the info on a new line.
    Where's MagicSpeed?
    Quote from: 'matt'
    He's playing a game called IRL. Great graphics, *censored* gameplay.

    alecsillidan

      Topic Starter


      Beginner

      Re: date log
      « Reply #2 on: July 14, 2010, 07:35:32 AM »
      Not working, '07' is not recognised as an internal or external command, operating program or batch file.
      It's too complicated this way, but I made it using just a file (Date.log) where is saved the date, time and username :D
      Thank you for the help!
      We never had to cheat 'cause we already won!

      gpl



        Apprentice
      • Thanked: 27
        Re: date log
        « Reply #3 on: July 14, 2010, 08:14:16 AM »
        What is the format of your date?
        please send the result of
        Code: [Select]
        echo %date%
        I suspect it is made up with slashes as dividers, in which case you need to remove them before using it in a filename

        is your logfile called just Date.log ?
        in which case, do this
        Code: [Select]
        >> date.log echo %date% %time%---%username%