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

Author Topic: display duration of batch file execution  (Read 8711 times)

0 Members and 1 Guest are viewing this topic.

Winfiem

    Topic Starter


    Newbie

    display duration of batch file execution
    « on: September 25, 2008, 07:57:53 AM »
    What dos code should I put in my existing dos xcopy backup file in order to display the duration (mins, secs, hundredths)  it took to execute, please?  I attach a sample backup batch file for information.

    Thanks,  Mark

    [Saving space - attachment deleted by admin]

    gpl



      Apprentice
    • Thanked: 27
      Re: display duration of batch file execution
      « Reply #1 on: September 25, 2008, 09:52:48 AM »
      Batch code isnt very good at working out durations, either use a piece of vbscript which can do it, or get your batch to reset the clock to midnight then just display the time when its finished !!
      Graham

      Jacob



        Hopeful

        Thanked: 1
        • Experience: Expert
        • OS: Windows XP
        Re: display duration of batch file execution
        « Reply #2 on: September 25, 2008, 10:07:17 AM »
        This should do it. This is only accurate to the second and not hundredths of a second.
        This only counts, you will need someones else's help to display how long it took for the xcopy.
        Code: [Select]
        @echo off
        set time=0
        set mtime=0
        :loop
        cls
        set /a time=%time% + 1
        If %time%==60 (
        set time=0
        set /a mtime=%mtime%+1
        )
        echo Runtime [%mtime% Minutes and %time% Seconds]
        ping 127.0.0.1 -n 2 > NUL
        goto loop
        )
        pause
        And I don't think you can do Milli seconds.

        And if it is 1 minute then you can be grammatically correct and display '1 Minute' rather than '1 Minutes'
        by using this:
        Code: [Select]
        @echo off
        set time=0
        set mtime=0
        :loop
        cls
        set /a time=%time% + 1
        If %time%==60 (
        set time=0
        set /a mtime=%mtime%+1
        )
        If %mtime%==1 (
        echo Runtime [%mtime% Minute and %time% Seconds]
        ping 127.0.0.1 -n 2 > NUL
        goto loop
        )
        echo Runtime [%mtime% Minutes and %time% Seconds]
        ping 127.0.0.1 -n 2 > NUL
        goto loop
        )
        pause

        « Last Edit: September 25, 2008, 11:20:38 AM by Jacob »

        Dias de verano

        • Guest

        Winfiem

          Topic Starter


          Newbie

          Re: display duration of batch file execution
          « Reply #4 on: September 26, 2008, 02:48:14 AM »
          Guys,

          Many thanks for this - I'll give it a go.  Your conversation, Dias, with Frank in August, is an educational nugget for me even though I couldn't follow much of the syntax.

          Most impressed with the speedy responses - very kind,

          Regards, Mark

          Jacob



            Hopeful

            Thanked: 1
            • Experience: Expert
            • OS: Windows XP
            Re: display duration of batch file execution
            « Reply #5 on: September 26, 2008, 09:22:58 AM »
            No problem, sorry I couldn't be of greater help.