Search found 233 matches

by Sponge Belly
03 May 2025 09:03
Forum: DOS Batch Forum
Topic: …and we’re back!
Replies: 3
Views: 64

…and we’re back!

Hello All,

Looks like normal service has resumed! :)

- SB
by Sponge Belly
26 Jan 2025 11:08
Forum: DOS Batch Forum
Topic: How to pass a variable in batch/javascript hybrid
Replies: 6
Views: 4752

Re: How to pass a variable in batch/javascript hybrid

Hi Steffen, Brilliant workaround for ensuring Unicode I/O. 8) But please explain this line: for /f "tokens=2,6 delims={:," %%a in ('type "foo.tmp~"') do echo %%a*%%b Why all the tokens and delims, and why the asterisk between %%a and %%b? And why use TYPE inside the in (...) clause of the for /f loo...
by Sponge Belly
18 Dec 2024 10:47
Forum: DOS Batch Forum
Topic: is there a way to display the list without the quotation marks when ampersands present?
Replies: 3
Views: 7118

Re: is there a way to display the list without the quotation marks when ampersands present?

Hi nnnmmm,

Here’s an old trick I learnt from Jeb:

Code: Select all

for %%^" in ("") do echo(%%~"poison characters ! ^ & < | > without quotes%%~"
Read this SO Q&A for the full story.

Ho ho ho! :)

- SB
by Sponge Belly
17 Oct 2024 10:52
Forum: DOS Batch Forum
Topic: date and time format inconsistencies
Replies: 13
Views: 56371

Re: date and time format inconsistencies

Hello All,

npocmaka outlines a locale-independent method for capturing the current date and time using makeCab in the second answer to this SO Question.

I don’t know why it isn’t used more widely. :?

HTH! 8)

- SB
by Sponge Belly
11 Sep 2024 14:36
Forum: DOS Batch Forum
Topic: scrolling region test
Replies: 8
Views: 58281

Re: scrolling region test

Hi All,

Ed Dyreen and Dave Benham discussed capturing the backspace character in the Send Backspace Key in Batch topic as far back as 2012.

HTH! :)

- SB
by Sponge Belly
11 Aug 2024 10:17
Forum: DOS Batch Forum
Topic: OT: WordStar for DOS 7 Archive
Replies: 1
Views: 21778

OT: WordStar for DOS 7 Archive

Hello All! :) Slightly off topic, but I thought some of you DOS veterans might be interested in this. SF author Robert J Sawyer has put together a WordStar archive . For those of you who don’t know, WordStar was a much loved word processor that predates Word and even Windows itself. The archive incl...
by Sponge Belly
19 Jul 2024 15:33
Forum: DOS Batch Forum
Topic: How to detect CRLF at the end of file?
Replies: 4
Views: 54772

Re: How to detect CRLF at the end of file?

Hi Saso,

Try this one-liner:

Code: Select all


findStr /v $ file.txt >nul && echo(no CR-LF at EOF || echo(file ends with CR-LF

Only works for CR-LF (Windows) files, and not LF (Unix) files.

HTH! :)

- SB
by Sponge Belly
30 Jun 2024 17:51
Forum: DOS Batch Forum
Topic: How to output a range of lines from a text file using findstr
Replies: 5
Views: 35892

Re: How to output a range of lines from a text file using findstr

Hi Shodan! :) This has been on my to-do list for a long time. Your post finally spurred me into action. Searching the web yielded nothing. There are plenty of range generators, but no code examples. No matter, a straightforward problem… or so I thought until I tried to write the program. It proved t...
by Sponge Belly
02 Jun 2024 13:04
Forum: DOS Batch Forum
Topic: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !
Replies: 11
Views: 60757

Re: Fast and robust :GetSubstringIndex :ReplaceString :CreateRandomStringPS functions !

Hi Shodan,

Very ambitious! But what is your use-case? And why are you re-inventing the wheel? Just pass the string to JScript or PowerShell in an environment variable, let it chop up the string any way you want, and capture the output in an for /f loop.

Laters! :)

- SB
by Sponge Belly
30 May 2024 13:49
Forum: DOS Batch Forum
Topic: Another way to keep terminal window open
Replies: 1
Views: 7009

Re: Another way to keep terminal window open

Hi Samson,

Have you tried opening cmd.exe and running the batch file from the command line?

Hope this helps! :wink:

- SB
by Sponge Belly
01 May 2024 05:03
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 17853

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Hi Shodan, There should indeed be a terminating endLocal somewhere after the end of the for /f loop. Delayed expansion is explicitly disabled to prevent any ^ and ! characters in the line of input from being corrupted. But once the line has been read into the variable, delayed expansion can be safel...
by Sponge Belly
22 Apr 2024 13:44
Forum: DOS Batch Forum
Topic: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile
Replies: 8
Views: 17853

Re: Need help copying a line of text from a file to another (without mangling it) :AppendFileLineToFile

Hi Shodan,

I’m not sure what you’re trying to accomplish, but I suggest you read Calling Functions from a Library, especially Post #4 by Penpen.

HTH! :)

- SB
by Sponge Belly
10 Apr 2024 14:59
Forum: DOS Batch Forum
Topic: check file contains only printable 7-bit ASCII characters
Replies: 0
Views: 25083

check file contains only printable 7-bit ASCII characters

Hello All! :) A little proof-of-concept program I put together: @echo off & setLocal enableExtensions disableDelayedExpansion (call;) %= sets errorLevel to 0 =% for /f "tokens=*" %%A in ('chcp') do for %%B in (%%A) do set "cp=%%~nB" mode con cp select=437 >nul ((for /l %%I in (1 1 70) do pause) >nul...