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

Author Topic: Win/Batch: display progress of work  (Read 16425 times)

0 Members and 1 Guest are viewing this topic.

lwkt

    Topic Starter


    Rookie

    Win/Batch: display progress of work
    « on: August 26, 2009, 10:04:49 PM »
    Hi there,

    I am using batch file to collect files generated by other application.

    The elapse time of the collection process may take for 10 to 30 minutes depends
    on the number of files generated.

    I have told users to wait for the completion of process with following echo commands: -

    ===================================================

    ECHO Collecting information... Please be patient...
    ECHO.
    ECHO Will take 10 to 30 minutes...

    ===================================================

    Is it possible to display some work in progress message or
    putting a continuous ...... sign on the screen during the running of collection process?

    Thanks,
    Thomas

    smeezekitty

    • Guest
    Re: Win/Batch: display progress of work
    « Reply #1 on: August 26, 2009, 10:20:17 PM »
    not without seeing your batch code

    lwkt

      Topic Starter


      Rookie

      Re: Win/Batch: display progress of work
      « Reply #2 on: August 26, 2009, 11:26:57 PM »
      Here is the code:

      ============================================
      @ECHO OFF.
      EXTRACT.exe "File *.txt" > "date_time*.txt"
      rem
      ECHO Collecting information... Please be patient...
      ECHO.
      ECHO Will take 10 to 30 minutes...
      rem
      pause
      exit
      ===============================================

      Please be noted that EXTRACT.exe is an
      executable that use to collect required information
      and translate to text files. It is come with a
      proprietary application.

      Thanks,
      Thomas

      smeezekitty

      • Guest
      Re: Win/Batch: display progress of work
      « Reply #3 on: August 26, 2009, 11:33:41 PM »
      since the program is operating in the background
      i dont think you can show progress
      the best you can do is this have a spinning indicator like this
      | then / then -- then \
      even that would be hard
      maybe salmon_trout aka virus accuser or batch file basics may help

      lwkt

        Topic Starter


        Rookie

        Re: Win/Batch: display progress of work
        « Reply #4 on: August 27, 2009, 12:11:05 AM »
        Sorry, it is a foreground process.
        The correct code is: -

        ============================================
        @ECHO OFF.

        ECHO Collecting information... Please be patient...
        ECHO.
        ECHO Will take 10 to 30 minutes...
        rem
        EXTRACT.exe "File *.txt" > "date_time*.txt"
        rem
        pause
        exit
        ===============================================

        Spinning indicator is fine. At least it shows
        the collection process is still running.

        Thanks,
        Thomas

        BatchFileBasics



          Hopeful

          Thanked: 18
          Re: Win/Batch: display progress of work
          « Reply #5 on: August 27, 2009, 12:16:48 AM »
          it should be pretty straight forward.
          it would help if some one could extend my knowledge of making multi line variables...
          "%var%" = Hello
                         there

          but this is what i got so far
          Code: [Select]
          @echo off
          set msgg=Collecting information... Please be patient...
          set dly=Ping localhost -n 2 -w 1000 ^>nul ^& cls
          EXTRACT.exe "File *.txt" > "date_time*.txt"
          :wait
          %dly%
          echo %msgg% \
          %dly%
          echo %msgg% ^|
          %dly%
          echo %msgg% /
          %dly%
          echo %msgg% -
          goto wait

          OOPS
          new change of code, forgot most important piece "EXTRACT.exe "File *.txt" > "date_time*.txt""
          When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

          Salmon Trout

          • Guest
          Re: Win/Batch: display progress of work
          « Reply #6 on: August 27, 2009, 12:25:17 AM »
          Instead of passing a wildcard to Extract.exe and leaving it to finish, can't you pass every single file name you want it to process, one by one? If you counted them first, you could show a done/to do figure e.g. 1/127, then 2/127 then 3/127 etc (Or calculate percentage done)



          BatchFileBasics



            Hopeful

            Thanked: 18
            Re: Win/Batch: display progress of work
            « Reply #7 on: August 27, 2009, 12:27:30 AM »
            great idea  ;)

            sadly i must continue this is the morning
            When the power of love overcomes the love of power the world will know peace - Jimi Hendrix.

            smeezekitty

            • Guest
            Re: Win/Batch: display progress of work
            « Reply #8 on: August 27, 2009, 12:45:56 AM »
            try this
            Code: [Select]
            echo off
            cls
            set /A files=0
            echo please wait a few min
            for %%f in (*.txt) do set /A files=%%files+1
            set /A _done=0
            for %%x in (*.txt) do (
            cls
            EXTRACT.exe "File %%x" > "date_time%%x.txt"
            echo %%_done of %%files done
            set /A _done = %%_done+1
            )

            Salmon Trout

            • Guest
            Re: Win/Batch: display progress of work
            « Reply #9 on: August 27, 2009, 01:03:41 AM »
            smeezekitty, a reasonable first effort.  But. you are getting ordinary %variables% and single letter loop variables confused. What kind of animal is %%files? And a bit of delayed expansion is needed too. Maybe you could try the script out on some dummy files before posting?







            smeezekitty

            • Guest
            Re: Win/Batch: display progress of work
            « Reply #10 on: August 27, 2009, 01:26:43 AM »
            i tired it
            and it printed the variable name instead of printing there value
            why is that?
            it should have worked

            smeezekitty

            • Guest
            Re: Win/Batch: display progress of work
            « Reply #11 on: August 27, 2009, 01:35:48 AM »
            ok i think i got it figured out it seemed to work but i am not completely sure
            Code: [Select]
            echo off
            cls
            set /A files=0
            echo please wait a few min
            for %%f in (*.txt) do set /A files=%files%+1
            set /A _done=0
            for %%x in (*.txt) do (
            cls
            echo %_done% of %files% done
            set /A _done=%_done%+1
            EXTRACT.exe "File %%x" > "date_time%%x.txt"
            )

            lwkt

              Topic Starter


              Rookie

              Re: Win/Batch: display progress of work
              « Reply #12 on: August 27, 2009, 09:12:05 AM »
              Thank you for your suggestions.

              However, the number of files that Extract.exe would be generated were not constant.
              The suggestions from Salmon and Smeezekitty are not fit for my case.

              BatchFileBasics' suggestion sound interesting but the code
              just putting my program into endless loop of spinning
              indicator.  Any idea about the problem?

              Thanks,
              Thomas

              smeezekitty

              • Guest
              Re: Win/Batch: display progress of work
              « Reply #13 on: August 27, 2009, 11:49:29 AM »
              no
              it should work
              because it counts the files in the directory before it runs extract
              meaning you could have 1 10 or 1000 files it would still work fine

              lwkt

                Topic Starter


                Rookie

                Re: Win/Batch: display progress of work
                « Reply #14 on: August 27, 2009, 05:46:54 PM »
                Smeezekitty,

                Your code works perfect if we know the total number of files in the directory.

                However,  the function of  Extract.exe is to extract data from some anolog logging devices and then convert to text files. The amount of files generated depends on the data that collected before the requested period.
                Therefore, the number of files in the collected folder is unknown before Extract.exe is being run.

                My purpose of using progress indicator is to indicate that process of collection and data convertion is still running. Telling user to be patient.

                Thanks,
                Thomas