Search found 2429 matches

by dbenham
12 Nov 2020 18:10
Forum: DOS Batch Forum
Topic: jrepl: replace + append in cmd file
Replies: 1
Views: 2676

Re: jrepl: replace + append in cmd file

You definitely don't want the /M option if you are trying to process lines. I also don't see the purpose of /X in your case, but I don't see that it hurts either. If you specify your search as a regex, then you could use the /T option, including a search/replace for end of line. The regex is needed ...
by dbenham
08 Nov 2020 06:07
Forum: DOS Batch Forum
Topic: batch file PID
Replies: 6
Views: 6520

Re: batch file PID

The randomised UID isn't strictly necessary, however simplifies isolation of a given instance of the script should multiple instances be running. Ensuring the titles differ is necessary if there is a chance the script may be run in multiple instances at the same time. Unfortunately %RANDOM% is not ...
by dbenham
30 Oct 2020 09:34
Forum: DOS Batch Forum
Topic: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets
Replies: 550
Views: 1925324

Re: JREPL.BAT v8.6 - regex text processor with support for text highlighting and alternate character sets

Assuming the entire string is on a single line, then it is a rudimentary regular expression, though I wouldn't be surprised if your file had other text that might be mistakenly identified by the simple regular expression: jrepl "To:.*?;;" "" /i input.csv /o output.csv Explanation: To: - self explana...
by dbenham
29 Oct 2020 17:07
Forum: DOS Batch Forum
Topic: Determine Yes/No/All string for current locale
Replies: 17
Views: 16199

Re: Determine Yes/No/All string for current locale

I like it. You might want to include space in the delimiter list if you want the entire word without trailing space.
by dbenham
29 Oct 2020 08:46
Forum: DOS Batch Forum
Topic: A killer : in a comment
Replies: 15
Views: 10682

Re: A killer : in a comment

And this behaviour is a useful feature! %LOAD_ONLY_ONCE:call "%~dp0\libBase.cmd" := % If LOAD_ONLY_ONCE is undefined, the call is executed and there the LOAD_ONLY_ONCE macro is defined. Any further such line will execute only the macro. jeb Oooh - clever :!: But I think only useful if you want to m...
by dbenham
29 Oct 2020 08:23
Forum: DOS Batch Forum
Topic: A killer : in a comment
Replies: 15
Views: 10682

Re: A killer : in a comment

Probably the best option for comments within loops is to use %= UNDEFINED VARIABLE AS COMMENT =% . This can safely be used absolutely anywhere as long as the comment does not contain a % or : character. It even works as an inline comment. It is safe because it is impossible to define a variable with...
by dbenham
28 Oct 2020 18:51
Forum: DOS Batch Forum
Topic: A killer : in a comment
Replies: 15
Views: 10682

Re: A killer : in a comment

I remember a lot of it, but believe me, I frequently reference the rules I wrote because I can't remember everything either. At least I usually remember enough to know when to look it up :roll:
by dbenham
28 Oct 2020 18:23
Forum: DOS Batch Forum
Topic: A killer : in a comment
Replies: 15
Views: 10682

Re: A killer : in a comment

Obviously this is linked to the %FULL_SHORT:\=" "% variable expansion when that variable is empty. But I don't understand the relationship with a ':' anywhere in the following comment! :shock: Anybody has clues? It is well understood :wink: The percent expansion does not parse in an intuitive way w...
by dbenham
28 Oct 2020 17:36
Forum: DOS Batch Forum
Topic: A killer : in a comment
Replies: 15
Views: 10682

Re: A killer : in a comment

No, :# will always generate a syntax error within a parenthesized block if it is not immediately followed by a valid command on the next line. For example: @echo off ( echo 1 :# Syntax error echo 2 ) But move the 2nd echo to immediately follow the :# and all is good @echo off ( echo 1 :# This commen...
by dbenham
23 Oct 2020 15:39
Forum: DOS Batch Forum
Topic: Replacing "" by " in every line of a text file
Replies: 6
Views: 5399

Re: Replacing "" by " in every line of a text file

I am pretty sure your stated goal is not what you really want. Even if you manage to convert paired double quotes into a single double quote, the last lines will still have unbalanced quotes because the last field was already quoted. It looks to me like your source file is a corrupted CSV using semi...
by dbenham
06 Oct 2020 17:40
Forum: DOS Batch Forum
Topic: JREN.BAT v2.8 - Rename files/folders using regular expressions
Replies: 78
Views: 164911

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

That is weird, I don't see how my code can do that. And working off a USB drive shouldn't make a difference. Have you tried the same steps with a simple REN instead of JREN? Your example should work just as well with REN. Please note that your first argument is a regular expression, meaning the dot ...
by dbenham
09 Sep 2020 04:09
Forum: DOS Batch Forum
Topic: LABEL Being Processed without GOTO or CALL
Replies: 13
Views: 9885

Re: LABEL Being Processed without GOTO or CALL

Good idea. I would never use it, but I see how it can be helpful to some.
by dbenham
07 Sep 2020 10:37
Forum: DOS Batch Forum
Topic: LABEL Being Processed without GOTO or CALL
Replies: 13
Views: 9885

Re: LABEL Being Processed without GOTO or CALL

There is a problem with this code snippet: IF ERRORLEVEL 1 EXIT /b %ErrorLevel% ________ That will generate a visible error if ERRORLEVEL is <= 0. Better to use ======================= as that character parses as white space, so no error. The equal sign is easier to type as well. Alternatively prefi...
by dbenham
30 Aug 2020 12:56
Forum: DOS Batch Forum
Topic: g.bat to jump between folders - need help to make it pure batch!
Replies: 16
Views: 14538

Re: g.bat to jump between folders - need help to make it pure batch!

I developed CDX.BAT to address the same issues long ago, based on an idea found at the ss64.org cmd forum . Rather than build an index of the entire volume(s), it allows each user to develop their own custom list of commonly accessed folders. Full help is available via CDX /? I haven't had a chance ...