Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :pushd_counter
- rem -- counts the number of pushd calls
- rem -- by Vasil "npocmaka" Arnaudov
- @echo off
- set prompt_backup=%prompt%
- prompt $+
- ( echo on
- for %%a in (1) do ( @rem
- )
- )>%temp%\p.tmp
- @echo off
- prompt %prompt_backup%
- set "prompt_backup="
- for /f "usebackq tokens=1,2,3 delims=() " %%P in ("%temp%\p.tmp") do (
- set pushes=%%P
- goto :end_for
- )
- :end_for
- call :strlen0.3 pushes
- del %temp%\p.tmp /s /q >nul
- goto :eof
- :strlen0.3 StrVar [RtnVar]
- setlocal EnableDelayedExpansion
- set "s=#!%~1!"
- set "len=0"
- for %%A in (2187 729 243 81 27 9 3 1) do (
- set /A mod=2*%%A
- for %%Z in (!mod!) do (
- if "!s:~%%Z,1!" neq "" (
- set /a "len+=%%Z"
- set "s=!s:~%%Z!"
- ) else (
- if "!s:~%%A,1!" neq "" (
- set /a "len+=%%A"
- set "s=!s:~%%A!"
- )
- )
- )
- )
- endlocal & if "%~2" neq "" (set %~2=%len%) else echo %len%
- exit /b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement