Help with DOS batch scripting

Discussion in 'Web Design & Coding' started by RagnaroK, Jan 19, 2004.

  1. RagnaroK

    RagnaroK Must be dreaming...

    Messages:
    673
    Location:
    Australia
    Hi,
    Just wondering if the following is possible:

    If I were to put this into a batch file, for example:
    Code:
    @echo off
    echo Copy done @
    date /t
    time /t
    
    The following would be displayed onscreen correct?
    Code:
    Copy done @
    Mon 01/01/0001
    00:01 AM

    Now what I want to do is to get the above info displayed onscreen like this instead:
    Code:
    Copy done @ Mon 01/01/0001 00:01 AM
    I want it on the one same line instead of the three lines? Is it possible? Thanks and any input is appreciated. :D
     
  2. the_tazinator

    the_tazinator Are we there yet?

    Messages:
    177
    Location:
    In a house
    This should do what you need to do:

    @ECHO OFF
    set timestamp=%date% %time%
    echo Copy done @ %timestamp%

    Sample output:

    Copy done @ Sun 01/18/2004 22:33:16.29
     
  3. Shamus MacNoob

    Shamus MacNoob Moderator Political User

    Messages:
    4,199
    Location:
    L'Ile Perrot Quebec
    Yes that looks right the echo command will display the message that follows the echo
     
  4. the_tazinator

    the_tazinator Are we there yet?

    Messages:
    177
    Location:
    In a house
    If you are not doing anything between the time recorded and the time displayed you could just do:

    @ECHO OFF
    Copy done @ %date% %time%
     
  5. RagnaroK

    RagnaroK Must be dreaming...

    Messages:
    673
    Location:
    Australia
    Just what I needed. Thank you very much.
    I'm interested in learning more of such programming, do you know where I can do that?

    Edit:
    Umm, got a problem. Are the %date% and %time% commands OS specific? Because I tested the commands on my WinXP system at home, and they worked fine, but I tried them on a WinNT system, and it doesn't show the date and time. :(
     
  6. AcftMecH

    AcftMecH OSNN Addict

    Messages:
    99
    dos commands

    you might already have something like this but here is a DOS commands website that is pretty good.

    Dos commands
     
  7. the_tazinator

    the_tazinator Are we there yet?

    Messages:
    177
    Location:
    In a house
    I think that those commands will only work on Windows 2000 and above. I haven't used an NT machine in a couple of years so I have dumped most of what I remember about it.