Search found 2176 matches

by dbenham
09 Apr 2019 07:46
Forum: DOS Batch Forum
Topic: How to sort file contents based on pattern?
Replies: 4
Views: 59

Re: How to sort file contents based on pattern?

Sorting numerically is one of the prime reasons I wrote JSORT.BAT v4.2 - Case sensitive sort with option for numeric sort . It is another hybrid JScript/batch utility. Full documentation is available via JSORT /? I believe you are looking for the highest numbered file, so the following options are n...
by dbenham
08 Apr 2019 06:06
Forum: DOS Batch Forum
Topic: how to include a batch file as module
Replies: 4
Views: 90

Re: how to include a batch file as module

Perhaps the simplest approach is to abandon the goal of putting multiple routines in one module.bat. Instead you can create a batFunctions folder to house a separate bat file for each routine. Then you simply need to make sure the batFunctions path is in in your PATH. Any batch script can then simpl...
by dbenham
07 Apr 2019 20:47
Forum: DOS Batch Forum
Topic: how to include a batch file as module
Replies: 4
Views: 90

Re: how to include a batch file as module

There is no exact corollary. But below is an interesting strategy. I can't remember who first posted this on DosTips. If you CALL a :subroutine, and that routine invokes another batch file, then the 2nd batch file automatically branches to a :subroutine with the same name. The 2nd batch returns imme...
by dbenham
05 Apr 2019 09:42
Forum: DOS Batch Forum
Topic: Convert 1111 2222 3333 in \x11\x11\x22\x22\x33\x33
Replies: 9
Views: 108

Re: Convert 1111 2222 3333 in \x11\x11\x22\x22\x33\x33

Due to the many limitations and idiosyncrasies of batch, I rarely use pure batch to manipulate text files anymore. I find it much easier to use JREPL.BAT . Once you learn regular expressions and study the JREPL options, it is usually fairly easy to get the result you need, and it is significantly fa...
by dbenham
23 Mar 2019 12:08
Forum: DOS Batch Forum
Topic: Problem with correctly quoting in a FOR /F loop
Replies: 7
Views: 348

Re: Problem with correctly quoting in a FOR /F loop

Thanks for your inputs, guys. To keep you updated: None of the proposed solutions were effective. Have a nice day. I'm pretty sure the info I provided should work, unless there is something important that you have not shown us. It might help to know the exact value of variable adb . Dave, I always ...
by dbenham
21 Mar 2019 07:52
Forum: DOS Batch Forum
Topic: Problem with correctly quoting in a FOR /F loop
Replies: 7
Views: 348

Re: Problem with correctly quoting in a FOR /F loop

No, single quotes never need to be escaped. Something like FOR /F %%A IN ('someCommand 'someParameter' additionlParameter') DO ... works just fine. Also, there should not be any need to CALL a command within the IN() clause, even if it happens to be a batch script. The primary problem stems from the...
by dbenham
19 Mar 2019 15:07
Forum: DOS Batch Forum
Topic: JREN.BAT v2.8 - Rename files/folders using regular expressions
Replies: 52
Views: 27736

Re: JREN.BAT v2.8 - Rename files/folders using regular expressions

Rather than worry about how many underscores are being replaced, I would simply look for all text that precedes the text you want to keep. In that way the same command will work no matter how many underscores you have. The simplest method is to use a look-ahead assertion. The regular expression veri...
by dbenham
13 Mar 2019 10:32
Forum: DOS Batch Forum
Topic: Simple log function does not work with some characters (such as parentheses or variables)
Replies: 6
Views: 282

Re: Simple log function does not work with some characters (such as parentheses or variables)

Once you enable delayed expansion, it is often advisable to use it through out, and it certainly doesn't hurt to use it. The reason why it may be wise to use delayed expansion if it is enabled is because ! literals within variables will need to be escaped if you use percent expansion while delayed e...
by dbenham
13 Mar 2019 08:37
Forum: DOS Batch Forum
Topic: Simple log function does not work with some characters (such as parentheses or variables)
Replies: 6
Views: 282

Re: Simple log function does not work with some characters (such as parentheses or variables)

First off, here is the minimum number of carets needed to get your existing code to work: REM Line without delayed expansion call :Write_Log - [Error] - The script isn't running under an administrator account or there has been no increase privileges ("Run as Administrator", from Windows Vista^^). RE...
by dbenham
11 Mar 2019 13:37
Forum: DOS Batch Forum
Topic: Edit Binary File
Replies: 17
Views: 669

Re: Edit Binary File

It is a beast :twisted: You did well. The only added JREPL feature I used was the /T option. The rest of what I wrote deals with capture groups and look ahead assertions, which are standard regex constructs, not really JREPL specific standard batch constructs like FOR, FOR /F, variables, delayed exp...
by dbenham
11 Mar 2019 08:50
Forum: DOS Batch Forum
Topic: Edit Binary File
Replies: 17
Views: 669

Re: Edit Binary File

aGermans' regular expression find/replace pair can be modified a bit to make it easier/shorter to write by using capture groups and lookahead groups. Something of the form: Capture Group 1 Look-ahead (BytesToMatchAndPreserve)ByteOrBytesToChange(?=AdditionalBytesToMatchAndPreserve) $1ReplacementBytes...
by dbenham
04 Mar 2019 09:03
Forum: DOS Batch Forum
Topic: Cardioid - Heart Curve
Replies: 6
Views: 336

Re: Cardoid - Heart Curve

I have never heard of a "cardoid". Did you mean "cardioid"?

That shape is not a cardioid because it has two cusps, where as a true cardioid has one cusp. If the bottom was rounded instead of having a point then it could be a cardioid.
by dbenham
26 Feb 2019 12:27
Forum: DOS Batch Forum
Topic: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like
Replies: 27
Views: 9083

Re: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like

I've updated the first post in this tread to version 1.6.

The /F and /FR options now support non-ASCII characters (8 bit characters with the high order bit set).


Dave Benham
by dbenham
25 Feb 2019 08:37
Forum: DOS Batch Forum
Topic: HASHSUM.BAT v1.6 - emulate md5sum, shasum, and the like
Replies: 27
Views: 9083

Re: HASHSUM.BAT v1.5 - emulate md5sum, shasum, and the like

Ouch, there may not be much that can be done. HASHSUM is totally dependent on native Windows command line tools, and they have inconsistent support for Unicode. It would help if you tell me which options you used when the code fails. Both the code to generate hashes and the code to check hashes are ...
by dbenham
20 Feb 2019 10:52
Forum: DOS Batch Forum
Topic: running any external command safely !
Replies: 10
Views: 615

Re: running any external command safely !

I have only casually browsed this topic, so I may be barking up the wrong tree... But perhaps your problem has something to do with the intermittent XP bug when a FOR /F IN() clause contains an unquoted/unescaped token delimiter . Remember that one :!: :?: :twisted: I definitely see an unquoted/unes...