Search found 36 matches

by noprogrammer
12 Mar 2019 09:43
Forum: DOS Batch Forum
Topic: Reconcile files to be deleted with list?
Replies: 7
Views: 7539

Re: Reconcile files to be deleted with list?

Thanks Steffen, yes, it does work. I've got both cases for "use" and "remove" now:

Code: Select all

For /f "delims=" %%f In ('dir /b *.xml^|findstr /lb "%Exceptions: =.xml %"') Do (...)
For /f "delims=" %%f In ('dir /b *.xml^|findstr /lv "%Exceptions: =.xml %"') Do (...)
So far, it seems to work fine.
by noprogrammer
11 Mar 2019 17:38
Forum: DOS Batch Forum
Topic: Reconcile files to be deleted with list?
Replies: 7
Views: 7539

Re: Reconcile files to be deleted with list?

(Not sure if I understood the previous approach.) Anyway, here's the actual data. First off, I run the line <"%ProgramFiles%\Firefox\search.json" jq -r ".visibleDefaultEngines|join(\",\")" and save its output to a variable which looks like: google-2018 bing amazon-en-GB chambers-en-GB ddg ebay-uk tw...
by noprogrammer
10 Mar 2019 11:45
Forum: DOS Batch Forum
Topic: Reconcile files to be deleted with list?
Replies: 7
Views: 7539

Re: Reconcile files to be deleted with list?

Basically this works, but it will not only match foo.log, bar.log and baz.log but bar-tender.log or baz-2019.log as well.
Findstr will merely do what supposed to when run like

Code: Select all

... findstr /r /c:"^bar.log$" ...
So I'm not sure if findstr can be used for the filter logic.
by noprogrammer
10 Mar 2019 10:17
Forum: DOS Batch Forum
Topic: Reconcile files to be deleted with list?
Replies: 7
Views: 7539

Reconcile files to be deleted with list?

I've got a directory with many files (all with the same extension) and just need to keep a part of them, the rest should be deleted. The files to keep are stored in the variable %Exceptions% e.g. "foo bar baz" (generated by another process). I'd like to keep this as flexible as possible, i.e. the sc...
by noprogrammer
26 Jan 2019 06:23
Forum: DOS Batch Forum
Topic: How to store %Errorlevel% to variable for later use?
Replies: 2
Views: 5044

Re: How to store %Errorlevel% to variable for later use?

I tried it, it works as well if entered manually, but it won't work in my script. But I guess I've found the culprit, it's Setlocal enableDelayedExpansion enableExtensions The errorlevel handling works as expected without enableDelayedExpansion , however I can't do without it. I'm unsure what's best...
by noprogrammer
25 Jan 2019 04:50
Forum: DOS Batch Forum
Topic: How to store %Errorlevel% to variable for later use?
Replies: 2
Views: 5044

How to store %Errorlevel% to variable for later use?

I need to extend a script by the ability to check the output of a text dump. The script has to know the existence of a specific pattern and should store its state to a variable (0 or 1, basically). The text dump will be some formatted xml output and the pattern looks like <!-- foo:1 --> followed by ...
by noprogrammer
03 Dec 2016 08:42
Forum: DOS Batch Forum
Topic: Save first match in variable, ignore rest
Replies: 2
Views: 3212

Save first match in variable, ignore rest

Hi, I want to set the default (local) printer in a script. Basically, what I do is checking the default printer device. If it's "Adobe PDF", I want to look for another device and make it the default printer. I've got that part of the script already. The line wmic Printer where name!='Adobe...
by noprogrammer
03 Dec 2016 07:43
Forum: DOS Batch Forum
Topic: Asterisk masking in For loop: best practice?
Replies: 7
Views: 8240

Re: Asterisk masking in For loop: best practice?

Thanks alot for the many solutions, I tried Aacini's version (haven't fully understood the masking yet) and it works.
The code just looks a bit "awkward" (and will get a comment).
Compo's reg query trick is another good approach - I'll check it out, too.
by noprogrammer
30 Nov 2016 08:27
Forum: DOS Batch Forum
Topic: Asterisk masking in For loop: best practice?
Replies: 7
Views: 8240

Asterisk masking in For loop: best practice?

Hi, I'm working on a deletion script for Adobe software which aims at the update "nagware" (AdobeAAMUpdater-1.0 etc.). My script also deletes two registry keys added by Acrobat on each update: @echo off Setlocal enableExtensions enableDelayedExpansion REM (...) Set AcrContextItems=^ HKLM\S...
by noprogrammer
30 Nov 2016 08:13
Forum: DOS Batch Forum
Topic: File requirement checks as one liner?
Replies: 2
Views: 3432

Re: File requirement checks as one liner?

Sorry for the late reply, of course you were right.
Initially I wanted to do add parameter expansion as well, thus the remnant /f option...
by noprogrammer
12 Oct 2016 07:12
Forum: DOS Batch Forum
Topic: File requirement checks as one liner?
Replies: 2
Views: 3432

File requirement checks as one liner?

Hi, I'm revising a script, looking for simplifications. The script needs three files to process. This is what its author originally wrote: If Not Exist 7z.dll Echo 7z.dll missing &Goto :EOF If Not Exist 7zFM.exe Echo 7zFM.exe missing &Goto :EOF If Not Exist 7zG.exe Echo 7zG.exe missing &...
by noprogrammer
09 Mar 2016 04:48
Forum: DOS Batch Forum
Topic: Detecting loopback device via batch
Replies: 6
Views: 7063

Re: Detecting loopback device via batch

aGerman, I now use the following script @echo off &SetLocal Set "rkey=HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" For /f "tokens=3*" %%? In ('reg query %rkey% /v "DataBasePath"') Do ( For /f "tokens=*" %%i In ('call type "%%~?\hosts"...
by noprogrammer
06 Mar 2016 17:20
Forum: DOS Batch Forum
Topic: Detecting loopback device via batch
Replies: 6
Views: 7063

Re: Detecting loopback device via batch

@penpen: Maybe I mixed something up - I meant the localhost "mapping": the Windows default is 127.0.0.1, some people change it to 0.0.0.0 later. Before appending new content the correct mapping must be detected. @aGerman: Thanks for the script, very cool concept! I changed it slightly and ...
by noprogrammer
05 Mar 2016 15:26
Forum: DOS Batch Forum
Topic: Detecting loopback device via batch
Replies: 6
Views: 7063

Detecting loopback device via batch

Hi,

I need a routine to detect which loopback device has been chosen within the hosts file, i.e.
127.0.0.1 or 0.0.0.0: I need to return the appropriate value as variable (for another batch file).

What do you think?
by noprogrammer
24 Nov 2015 16:13
Forum: DOS Batch Forum
Topic: Feasability question: fortunes
Replies: 9
Views: 8034

Re: Feasability question: fortunes

Quite impressing, thanks alot! I digged up an approach that works with the tool gawk . My biggest fortunes file includes 728 quotes. I finally switched to UTF-8 encoding, too. A single cmd script doing all the fortunes functionality would be very nice. My current approach includes 3 files, a cmd scr...