Search found 230 matches

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

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: 43317

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: 13280

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: 46848

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: 24187

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: 52317

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: 5059

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: 13683

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: 13683

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: 16693

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...
by Sponge Belly
10 Apr 2024 08:16
Forum: DOS Batch Forum
Topic: How to dynamically escape % symbols?
Replies: 4
Views: 10132

Re: How to dynamically escape % symbols?

Hi SIMMS7400,

You may want to read the Mask Password with Asterisk topic. ;)

- SB
by Sponge Belly
08 Apr 2024 13:34
Forum: DOS Batch Forum
Topic: Success or failure echo
Replies: 3
Views: 8753

Re: Success or failure echo

Hi Squashman! I didn’t know that about robocopy. Good to know, thanks! 8) Gussy, don’t use the "command && success || failure" syntax with robocopy. Follow the example on the SS64 web page referenced by Squashman. Make sure you start with the highest errorLevel and work your way down to the lowest. ...
by Sponge Belly
08 Apr 2024 08:34
Forum: DOS Batch Forum
Topic: Success or failure echo
Replies: 3
Views: 8753

Re: Success or failure echo

Hi Gussy! :) If a command executes successfully, it sets errorLevel to 0, a non-zero integer otherwise. There’s an easy way to test for this and to take appropriate action. The syntax goes a little something like this: command && ( success ) || ( failure ) So, your code example would be rewritten as...