Loading Effect in Batch

56,967

14

48

Published

Introduction: Loading Effect in Batch

This is second instructable .. so still go easy on me .. ty

This script is a loading script .. well it only looks like one , it doesn't actually load anything .. its if you just want the effect of something in a batch file to seem like it is loading ...
I will give you the script and i will show you how i did it ...
please leave a comment about what you thought ... Thanks

Also because of how awesome El Mano is =P
somewhere on the comments he has posted a better version of this..
Thanks El Mano =D .. saves me the work of posting it.

Step 1: Steal My Script

OK if you can't be bothered to see how it works then you can just steal my script . I attached it . so you will have to delete one of the 'b's off the file extension for it to be readable.. and you will have to edit what it says at the top of the script .. and remove the 'By iRule' at the bottom of the script.. if something doesn't work please pm me or leave a comment...

Step 2: How It Works

OK this is a pretty simple script ..
All it uses is:
ping localhost -n 2 >nul = pause for X seconds - i paused for 2 here
cls = clear the batch screen
echo = to display the loading bar and writing

All the script dose is:
display loading at 0
pause for X seconds
Clear screen
Display loading at 5
and it keeps doing this untill its at 100
pretty simpe eh?

Hope you liked it ... please comment and pm me with any question .....

Share

    Recommendations

    • Clocks Contest

      Clocks Contest
    • BBQ Showdown Challenge

      BBQ Showdown Challenge
    • Creative Misuse Contest

      Creative Misuse Contest

    48 Discussions

    2 things

    one is the ping command safe because last time I used ping in my batch code for my custom made ai system it deleted my ability to use Bluetooth on my laptop

    2 I've got a challenge. the challenge is, try and create a loading screen without using ping

    1 reply

    Yes, I agree, no offense but I don't trust the ping localhost part.

    dude, i want to ask something, how can i make multiple progress bar, i already copied the code 3 times but the first progress bar always got erased, i want it to have 3 progress bar when done, care to tell me which i should add??

    0
    user
    xlan

    2 years ago

    A good

    Thanks Now I used it for my OS :)

    Similar to the one El Mano posted, but with the percentage in the progress bar. Where it says <40 spaces> you need to add 40 spaces, because these comments strip them out:

    @echo off

    color 0A

    set "progbar= <40 spaces>"

    set /a pct=0

    :top

    cls

    echo(

    echo Loading...

    echo ---------------------------------------------

    echo %progbar% %pct%%%

    echo ---------------------------------------------

    ping localhost -n 2 > nul

    set progbar=[]%progbar:~0,-2%

    if %pct%==100 goto end

    set /a pct=%pct%+5

    goto top

    :end

    echo Done^^!!

    pause

    Just saw it didn't copy "set progbar=" correctly, that line has 40 spaces between = and ".

    You could use a for loop or just make a variable (that is the percentage of what is loaded already) and increase it by 5 and check to see if it is at 100. When it reaches 100, then the loop stops and goes to whatever it needs to do.

    Example:

    echo off

    color 0A

    mode 300

    ::/\ You don't have to put this line in

    cls

    set /a "percent=0"

    set /a "loaded="

    :A

    echo Loading... Please wait

    echo ---------------------------------------

    echo %loaded% = %percent%% ]

    echo ---------------------------------------

    set /a "percent=%percent%+5"

    set /a "loaded=%loaded%+'|'"

    :B

    ::Whatever you need to do after it loads...

    You get the idea, right? This isn't perfect. Don't copy it into your editor and run it because the program doesn't work, but the idea does.

    I think that this is pointless in a actual batch program where you want to get something done. But, It would be good in a batch movie. If I were going to put a loading command, then I would actually make the loading screen real. For instance, It would only show for the amount of time to load, with you can do with the call command.

    2 replies

    It would be useful if you were making a script for a customer who isn't really tech savvy and you wanted to show the progress so that he/she doesn't think the program has stalled. In example a backup script where each 10% takes about, say, three minutes.

    cheers I think ? ... i know it would be pretty pointless in an actual script but i thought that might come useful to someone like someone making a movie

    Why do you use the ping command? You better use the timeout command

    timeout -t 2 >NUL

    1 reply

    Because the timeout command (after what I've read) doesn't really do things in exactly the amount of seconds it's supposed to do. Many will swear to to using ping as well because it uses less processor power (hardly an issue today). In the end it really doesn't matter; use whatever works!

    This is a cool program, but it takes up a lot of space, making your file large and hard-to-edit. This is a much shorter, if more complicated, way:

    @echo off
    title Loading... By El Mano
    color 0a
    set load=
    set/a loadnum=0
    :Loading
    set load=%load%()
    cls
    echo.
    echo Loading... Please Wait...
    echo ----------------------------------------
    echo %load%
    echo ----------------------------------------
    ping localhost -n 2 >nul
    set/a loadnum=%loadnum% +1
    if %loadnum%==20 goto Done
    rem You can set the number of ()'s as whatever you rem want but remember: in your "loading box" you rem need 2 spaces for every () because "()" takes up rem 2 spaces. The above box has 40 spaces, so rem twenty repeats, adding 1 () every repeat.
    goto Loading
    :Done
    echo.
    pause
    rem *your action here*
    exit

    Feel free to modify, use, or ignore this. It's not copyrighted.

    5 replies

    Hi i know this was all the way back in 2009 but I was wondering if you could explain this a little bit i dont understand the
    " set load=%load%"
    why not just
    "set load=()"?

    This script works by making a line of ()'s across the screen. Each time it loops, it adds a () to the echoed script, so the first time it loops it echoes "()," then second time "()()", the third time "()()()", and so on.

    Set load=%load%()

    takes what %load% already contains, a number of ()'s, and adds another () to the end of the line, so that with each loop the screen echoes one more ().

    yeah thankyou for commenting so quickly i was looking at it at realizit it was kinda like
    %number%+1
    but for a variable very cool thank you ^.^