Search found 43 matches

by Thor
27 Oct 2016 10:34
Forum: DOS Batch Forum
Topic: Batch Script to make ColorShow Checkerboards
Replies: 10
Views: 7983

Re: Batch Script to make ColorShow Checkerboards

Very cool!
Here is my chessboard sample:

Code: Select all

checkboard.bat  /a8 /d8 /w6 /h3 /c0f /i0 /bbb

But I've noticed the border width from top/bottom are not the same as left/right.
Could you fix that?
by Thor
01 Oct 2016 11:41
Forum: DOS Batch Forum
Topic: Your top picks out of the forum threads and posts
Replies: 4
Views: 4554

Re: Your top picks out of the forum threads and posts

Here are some of the useful batch scripts that I've found pretty handy: Encrypt username / password? http://www.dostips.com/forum/viewtopic.php?f=3&t=7428 Compare two files and send common strings to another file http://www.dostips.com/forum/viewtopic.php?f=3&t=7421 js/vbs/html/hta and more ...
by Thor
01 Jul 2016 16:04
Forum: DOS Batch Forum
Topic: CMD not setting variables in the same line
Replies: 12
Views: 8403

Re: a problem in CMD (Please guide me)

thefeduke wrote:This would work if the DOS window had been started with delayed environment variable expansion enabled.
...
John A.

This will do the trick:

Code: Select all

start "" /B cmd /v:on /k "echo. & set k=1 & set j=20 & for /L %i in (!k!,1,!j!) do @echo %i
by Thor
01 Jul 2016 11:33
Forum: DOS Batch Forum
Topic: CMD not setting variables in the same line
Replies: 12
Views: 8403

Re: a problem in CMD (Please guide me)

Or you could do in 2 lines:

Code: Select all

set k=1 & set j=20
for /L %i in (%k% 1 %j%) do @echo %i
by Thor
25 May 2016 10:30
Forum: DOS Batch Forum
Topic: Calling functions from a library
Replies: 5
Views: 6796

Re: Calling functions from a library

"fnLib.bat" @echo off rem Limited up to 9 parameters goto %~1 %~2 %~3 %~4 %~5 %~6 %~7 %~8 %~9 :IsPingable comp ret setlocal for /f "tokens=2" %%a in ( '"ping -a -n 1 -4 "%~2" | Find "Pinging" 2>nul"') do set name=%%a endlocal & set %~3=%name% pin...
by Thor
23 May 2016 18:17
Forum: DOS Batch Forum
Topic: Replace specific line in a .txt with text
Replies: 8
Views: 23012

Re: Replace specific line in a .txt with text

Another way without the need to provide the line index is like this: "text_replace.bat" @echo off setlocal EnableDelayedExpansion cls echo input.txt: ( echo Batch echo is echo dumb ) > input.txt type input.txt echo. for /f "delims=:" %%a in ('type input.txt ^|findstr /nc:^"%...
by Thor
23 May 2016 14:32
Forum: DOS Batch Forum
Topic: Replace specific line in a .txt with text
Replies: 8
Views: 23012

Re: Replace specific line in a .txt with text

This batch file make use of a temp file. ::"text_replace.bat" @echo off setlocal EnableDelayedExpansion cls echo input.txt: ( echo Batch echo is echo dump ) > input.txt type input.txt echo. set count=0 ( for /f "tokens=*" %%a in ('type input.txt') do ( set /a count+=1 if !count! ...
by Thor
23 May 2016 11:15
Forum: DOS Batch Forum
Topic: Using the strLen function with my script. Please Help
Replies: 11
Views: 9130

Re: Using the strLen function with my script. Please Help

This use the "strlen.exe" utility from Aacini http://www.dostips.com/forum/viewtopic.php?f=3&t=3428&p=17101&hilit=strlen.hex#p17101 @echo off set Total_Dirs=0 for /f %%a in ('dir /b /ad') do set /a Total_Dirs+=1 setlocal enabledelayedexpansion set Files=0 for /f %%a in ('dir /b...
by Thor
14 May 2016 10:15
Forum: DOS Batch Forum
Topic: Listb - a file explorer/viewer inside the console window
Replies: 27
Views: 127828

Re: Listb - a file explorer/viewer inside the console window

You're absolutely right, my default background is blue that's why I could not see the highligted color (still in blue), I've changed it to 2 (green) and it's working fine now. Thanks for explaining and for a wonderful tool.
by Thor
14 May 2016 09:45
Forum: DOS Batch Forum
Topic: Listb - a file explorer/viewer inside the console window
Replies: 27
Views: 127828

Re: Listb - a file explorer/viewer inside the console window

I have a question though, when running this batch file and using the cursor to move around, I don't know where the cursor is at since the file is not highlighted as the cursor move around, besides just the index number is updated, but I have no clue what file the cursor is at. It would be nice to ha...
by Thor
15 Apr 2016 09:31
Forum: DOS Batch Forum
Topic: Fille spaces from the end of a string via "FOR" command
Replies: 7
Views: 6608

Re: Fille spaces from the end of a string via "FOR" command

What's wrong with it? The issue is located in this line: set "MYVAR=[!line[%%f]!!space:~0,!x[%%f]!!]" You cannot use delayed expanded values within the same delayed expansion step, because the exclamation marks ('!') are used to define these variables. In your case the processor is readin...
by Thor
15 Apr 2016 09:29
Forum: DOS Batch Forum
Topic: Fille spaces from the end of a string via "FOR" command
Replies: 7
Views: 6608

Re: Fille spaces from the end of a string via "FOR" command

You could use somethinig like this: @echo off set textvar=some text set textvar=%textvar% &rem 50 spaces set textvar=%textvar:~0,50% echo length 1 2 3 4 5 6_ echo length _123456789012345678901234567890123456789012345678901234567890_ echo textvar=_%textvar%_ Output c:\ length 1 2 3 4 5 6_ length...
by Thor
14 Apr 2016 23:17
Forum: DOS Batch Forum
Topic: Fille spaces from the end of a string via "FOR" command
Replies: 7
Views: 6608

Re: Fille spaces from the end of a string via "FOR" command

I've tried to fill blank spaces to the end of all filenames in a directory to make all of them with a 50 characters long. Here is my batch file: @echo off setlocal enabledelayedexpansion set i=0 for /f %%a in ('dir /b') do ( set /a i+=1 set "line[!i!]=%%a" strlen line[!i!] set /a fs=50-!er...