Batch Animated Text

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Flaming_PC
Posts: 1
Joined: 26 Mar 2015 07:36

Batch Animated Text

#1 Post by Flaming_PC » 26 Mar 2015 07:43

How do i do animated text like the following:
frame 1) H
frame 2) HE
frame 3) HEL
frame 4) HELL
frame 5) HELLO
but yet, i dont want to do:
echo H
ping localhost -n 1 >nul
cls
echo HE
because it takes up a lot of space and time

Thanks in Advanced :lol:

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Batch Animated Text

#2 Post by aGerman » 26 Mar 2015 17:55

Code: Select all

@echo off &setlocal
:: create a backspace character
for /f %%i in ('"prompt $H &for %%b in (1) do rem"') do set "bs=%%i"

:: animate the string
for %%i in (
  H E L L O "," " " W O R L D !
) do (<nul set /p "=.%bs%%%~i" & >nul ping -n 1 localhost)

:: add a line break
echo(

pause

As you can see the characters are separated by spaces. Token separators (such as spaces or commas) have to be enclosed into quotation marks.

Regards
aGerman

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Batch Animated Text

#3 Post by foxidrive » 26 Mar 2015 18:24

This is a simple method to solve your question:

Code: Select all

@echo off
for %%a in (H HE HEL HELL HELLO) do (
cls
echo %%a
ping -n 2 "">nul
)
pause

carlsomo
Posts: 91
Joined: 02 Oct 2012 17:21

Re: Batch Animated Text

#4 Post by carlsomo » 17 Apr 2015 20:37

SpinSpell.bat ["Message goes here"] [spincount] [spindelay]

Code: Select all

@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
for /f %%a in ('"prompt $H&for %%b in (1) do rem"') do set "$BS=%%a"
SET /A SpinCount=7,MaxSpinCount=30,Spin_Delay=4,ctr=0
SET "_MSG=ÛÛÛÛÛÛÛÛÛÛÛÛÛ"
IF NOT [%1]==[] (
  SET "_MSG=%~1"
  if defined %~1 set "_msg=!%~1!"
)
IF NOT [%2]==[] SET /A SpinCount=%~2
IF NOT [%3]==[] SET /A Spin_Delay=%~3
IF %SpinCount% GTR %MaxSpinCount% SET /A SpinCount=MaxSpinCount
SET "Spinner=³/Ä\"
call :strln _msg slen
set/a slen-=1
FOR /L %%a in (0 1 %slen%) DO (
  FOR /L %%A IN (1,1,%SpinCount%) DO (
    CALL :Delay %Spin_Delay%
    <nul CALL SET/P="%$BS%%%Spinner:~!ctr!,1%%"
    SET /A CTR=%%A %% 4
  )
  <nul set/p="%$BS%!_MSG:~%%a,1! "
)
ENDLOCAL & EXIT /B

:Strln
( SetLocal
  set "str=A!%~1!"
  set "len=0"
  for /L %%A in (12,-1,0) do (
    set /a "len|=1<<%%A"
    for %%B in (!len!) do if "!str:~%%B,1!"=="" set /a "len&=~1<<%%A"
  )
)
EndLocal&( REM RETURN VALUES
  if "%~2" NEQ "" set/a %~2=%len%
)&exit /b %len%

:Delay centiseconds
setlocal
set/a delay=%~1
for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "time1=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100
:wait
  for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "time2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=time2-time1"
  if %tDiff% lss 0 set /a tDiff+=24*60*60*100
  if /i %tDiff% geq %delay% endlocal&goto :eof
goto :wait
Last edited by carlsomo on 21 Apr 2015 02:10, edited 1 time in total.

carlos
Expert
Posts: 503
Joined: 20 Aug 2010 13:57
Location: Chile
Contact:

Re: Batch Animated Text

#5 Post by carlos » 17 Apr 2015 21:55

Code: Select all

@Echo Off
SetLocal EnableDelayedExpansion
Set "txt=HELLO"
For /L %%# in (0,1,4) Do (Set /P "=!txt:~%%#,1!" <Nul
Ping.exe -l 0 -n 1 -w 500 1.0.0.0 >nul
)
Echo(
PAUSE
Goto :Eof


Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: Batch Animated Text

#6 Post by Yury » 18 Apr 2015 02:50

Code: Select all

@powershell "gc '%~f0'|select -skip 1|%%{$_.getenumerator()|%%{write-host $_ -nonewline -foregroundcolor yellow -backgroundcolor darkgreen;sleep -milliseconds 100};''}"& pause>nul& exit/b


Hello, Flaming_PC!

Here you can place
any large text.

AiroNG
Posts: 46
Joined: 17 Nov 2013 15:00
Location: Germany

Re: Batch Animated Text

#7 Post by AiroNG » 18 Apr 2015 07:22

carlsomo wrote:SpinSpell.bat ["Message goes here"] [spincount] [spindelay]

Code: Select all

*snip*
:wait
  set timen=%time: =%
  if /i %timen% geq %time2% goto :end
goto :wait
*snip*


shouldn't that be:

Code: Select all

set timen=%time:~0,8% 
?

[/code]
Because otherwise i get a Syntax error message:

Code: Select all

 D:\set timen=15:15:02,59
"59" kann syntaktisch an dieser Stelle nicht verarbeitet werden.


but even without the error it wont work. it shows me literally nothing.
Is there an additional error in the script or am i just to stupid to use it? :mrgreen:

Yury
Posts: 115
Joined: 28 Dec 2013 07:54

Re: Batch Animated Text

#8 Post by Yury » 18 Apr 2015 11:14

Code: Select all

@for /f %%i in ('^<"%~f0" find/c /v ""') do @(
  for /f "delims=:" %%j in ('findstr/enc:"& :::::" "%~f0"') do @<"%~f0" (
   for /f %%k in ('forfiles /m "%~nx0" /c "cmd /c echo 0x08"') do @(
    for /l %%l in (1 1 %%i) do @(
     set x=& set/p x=&if %%l gtr %%j (
      if not defined x (echo.) else (
       if defined * (echo.) else (set *=*)
       for /f "delims=" %%m in ('cmd/u/v/c echo.!x!^| more^| findstr/n "^"') do @set y=%%m& (
        for /f "delims=" %%n in ('cmd/v/c echo."!y:*:=!"') do @<nul (
         if %%n neq " " (if %%n neq "=" (set/p=%%n) else (set/p=.%%k=)) else (set/p=.%%k %)
         >nul ping -n 1 -w 100 ""
        )
       )
      )
     )
    )
   )
  )
 )
@pause>nul& exit/b& :::::
     

Hello, Flaming_PC!

Here you can place
any large English text.

"="="="="="="="="=

carlsomo
Posts: 91
Joined: 02 Oct 2012 17:21

Re: Batch Animated Text

#9 Post by carlsomo » 18 Apr 2015 12:27

AiroNG

My time is format h:mm:ss.hs yours has a comma h:mm:ss,hs
so add a comma to the delimeters in this for loop in the delay routine:

Code: Select all

for /f "tokens=1-4 delims=:.," %%a in ("%time1%") do (


Then it should work. I have only tested on Win7.

AiroNG
Posts: 46
Joined: 17 Nov 2013 15:00
Location: Germany

Re: Batch Animated Text

#10 Post by AiroNG » 18 Apr 2015 17:36

carlsomo wrote:AiroNG

My time is format h:mm:ss.hs yours has a comma h:mm:ss,hs
so add a comma to the delimeters in this for loop in the delay routine:

Code: Select all

for /f "tokens=1-4 delims=:.," %%a in ("%time1%") do (


Then it should work. I have only tested on Win7.



So I am stupid then :)
Ok, i will test it after i get back home. Thank you.

carlsomo
Posts: 91
Joined: 02 Oct 2012 17:21

Re: Batch Animated Text

#11 Post by carlsomo » 18 Apr 2015 21:25

AiroNG

I apologize for not recognizing the variables in DOS related to regional and language settings. I am usually pretty happy getting something to work in one version, mine. :wink:

Carl

Post Reply