Search found 222 matches

by Sponge Belly
12 Dec 2012 14:50
Forum: DOS Batch Forum
Topic: Quotes, Parens, and GOTOs in Delayed Expansion
Replies: 1
Views: 2312

Quotes, Parens, and GOTOs in Delayed Expansion

Hello All! I have the following block of code in my win2unix program: setlocal enabledelayedexpansion if "%~1"=="" (if /i "!cmdcmdline!"=="!cmdcmdline:%~n0=!" ( endlocal & goto usage)) else ( if /i "!cmdcmdline!" neq "!cmdcmdline:%~n0=!"...
by Sponge Belly
03 Dec 2012 15:00
Forum: DOS Batch Forum
Topic: bowling, anyone?
Replies: 7
Views: 9947

bowling, anyone?

Hi Everyone! Since Christmas is a time for nostalgia, I thought I'd remind you about Elf Bowling. It was first released by NVision Design back in November, 1999. It instantly went viral and many sequels followed. But the original is surprisingly difficult to get hold of... until now! There's a link ...
by Sponge Belly
24 Nov 2012 15:54
Forum: DOS Batch Forum
Topic: Another take on safe string replace
Replies: 19
Views: 14556

Re: Another take on safe string replace

Hi Carlos! I have learnt the hard way not to bother Liviu until he's had his morning coffee See Jeb's answer in this SO thread for an example of safe string return. And once you've absorbed that , you can try bending your mind around Dave Benham's Macros with Arguments . Dave says you can wrap any f...
by Sponge Belly
23 Nov 2012 15:36
Forum: DOS Batch Forum
Topic: Batch findstr with quotes
Replies: 5
Views: 5753

Re: Batch findstr with quotes

Hi Raam! Welcome to DosTips. Maybe something like this might help... findstr /bl ^"\"%~1\"^" Remember that the dot (.) in the IP address is a findstr metacharacter and should either be escaped with a backslash (\) or turned off with findstr's /l (literal) switch. Also, I'm guessi...
by Sponge Belly
23 Nov 2012 14:45
Forum: DOS Batch Forum
Topic: store nth line of file in variable
Replies: 11
Views: 14346

Re: store nth line of file in variable

Thanks Ed!

That's what I thought.

Will file that link away for future reference.

Btw, who broke the bad news about more's 64k line limit? Does anyone have a link for that? I like to cite references in my blog posts whenever practicable.
by Sponge Belly
23 Nov 2012 14:16
Forum: DOS Batch Forum
Topic: store nth line of file in variable
Replies: 11
Views: 14346

Re: store nth line of file in variable

@Ed and @Mic: Well, I suppose if we had bigfile.txt and we wanted to isolate the 100th line in its own file, we could try the following from the command line: more +99 bigfile.txt | findstr /n $ | findstr /b "1:" ^ | (pause>nul&pause>nul&findstr $ >line100.txt) Should work with lon...
by Sponge Belly
23 Nov 2012 06:18
Forum: DOS Batch Forum
Topic: store nth line of file in variable
Replies: 11
Views: 14346

store nth line of file in variable

Hello All! A little program that accepts a line number, a filename, and an optional variable name from the command line and stores the contents of the line from the file in the variable (uses NTHLINE if none specified). @echo off & setlocal enableextensions set "a2z=abcdefghijklmnopqrstuvwx...
by Sponge Belly
23 Nov 2012 04:43
Forum: DOS Batch Forum
Topic: Another take on safe string replace
Replies: 19
Views: 14556

Re: Another take on safe string replace

Thanks for enlightening me, Liviu!

And apologies for saying your code would choke on control characters. I don't know why I thought that. Maybe if I read first and typed later...
by Sponge Belly
23 Nov 2012 04:17
Forum: DOS Batch Forum
Topic: Windows Narrator.bat (Read from file)
Replies: 7
Views: 7478

Re: Windows Narrator.bat (Read from file)

Hi Boombox! Have you tried Best Free Windows Narrator Voices ? Some good links there. There are also rumours that ETI Eloquence voices can be made to work with NVDA (an open source screen reader for Windows), but it's legally murky and I couldn't possibly comment further... On a lighter note, you mi...
by Sponge Belly
22 Oct 2012 08:46
Forum: DOS Batch Forum
Topic: update to win2unix
Replies: 8
Views: 9216

update to win2unix

Hello All! Everyone knows this old trick of converting Unix text files to Windows format: more unix.txt > win.txt Btw, more waits for keypress after scrolling 65,534 lines no matter what. But going the other way (from Windows to Unix) is less straightforward. But with a little chicanery and a lot of...
by Sponge Belly
06 Oct 2012 07:18
Forum: DOS Batch Forum
Topic: Another take on safe string replace
Replies: 19
Views: 14556

Re: Another take on safe string replace

Classic newbie error. But when I went back to add the code tags, someone had beaten me to it. Thanks, whoever you are! Anyways, I wrote the program to see if I could exploit findstr /o ^^. I acknowledge that it is grossly inefficient, case insensitive, and that it will choke on ~, =, and *. But the...
by Sponge Belly
04 Oct 2012 17:06
Forum: DOS Batch Forum
Topic: Another take on safe string replace
Replies: 19
Views: 14556

Re: Another take on safe string replace

Hello All! Sorry for the late arrival. What did I miss? Anyways, I've cranked out a little program similar to Liviu's. Only my effort counts the occurrences of the substring in the source string and creates a 0-based index list of the position of each occurrence. @echo off & setlocal enableexten...