Search found 2170 matches

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

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

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

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

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

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

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

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

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

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...
by dbenham
13 Feb 2019 06:51
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 17
Views: 3414

Re: Delayed expansion fails in some cases

My previous post postulates that phase 2 checks to see if the first token is a batch script, and then the parser follows some alternate path if it is. At first I thought " Why the hell would phase 2 do that :?: :? " But then... of course :) Phase 2 is restarted if there is a CALL, and CALL needs to ...
by dbenham
12 Feb 2019 23:36
Forum: DOS Batch Forum
Topic: Delayed expansion fails in some cases
Replies: 17
Views: 3414

Re: Delayed expansion fails in some cases

I think i've read before that delayed Expansion "differs" between command and parameter string (although the consequences were different), but i cannot remember where; if i had to guess, i would say it was a post/code from jeb/dbenham/both - something like this: Yes, I described somewhere that the ...
by dbenham
12 Feb 2019 22:57
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 467

Re: Call and goto may fail when the batch file has Unix line endings

So here is my current understanding of the label scanner process: 1) The label scanner attempts to read one line at a time, but it is limited to a 512 byte buffer, and it only recognizes \r\n as end-of-line. So when it reads a "line" of data, it reads through the first encountered \r\n, or end-of-fi...
by dbenham
12 Feb 2019 21:42
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 467

Re: Call and goto may fail when the batch file has Unix line endings

I don't have time to do further investigation now, but I hope that these discoveries may help resolve one or both of these unexplained edge cases: Delayed expansion fails in some cases Examination of Linefeeds with CALL That was wishful thinking. I couldn't remember any details other than at least ...
by dbenham
12 Feb 2019 09:16
Forum: DOS Batch Forum
Topic: Call and goto may fail when the batch file has Unix line endings
Replies: 16
Views: 467

Re: Call and goto may fail when the batch file has Unix line endings

Ooooh, a cmd.exe regression test plan :!: :D That would be nice, but I can't imagine actually doing it: 1) It would probably take thousands of individual tests 2) Documenting each test and showing how it relates to the rules would be difficult - there are lots of many to many relationships. I simply...
by dbenham
12 Feb 2019 07:13
Forum: DOS Batch Forum
Topic: findstr /C:""" file.txt&&set found=1 FAILS
Replies: 6
Views: 197

Re: findstr /C:""" file.txt&&set found=1 FAILS

I'm not sure what you are attempting with your first two examples. But the last two give expected behavior - you cannot escape a quote once quoting has begun. So you can escape the first quote or the last quote, but not the middle one. Regarding my SO post that aGerman linked - the section on escapi...