Search found 23 matches

by Reino
27 Nov 2021 08:20
Forum: DOS Batch Forum
Topic: How to pipe the outcome of an if-statement to another command?
Replies: 4
Views: 3895

Re: How to pipe the outcome of an if-statement to another command?

That's some weird stuff, but it works. Thanks, jeb!
by Reino
22 Nov 2021 17:52
Forum: DOS Batch Forum
Topic: How to pipe the outcome of an if-statement to another command?
Replies: 4
Views: 3895

Re: How to pipe the outcome of an if-statement to another command?

So it's actually a bug. I see.
Thanks for your quick reply.
by Reino
22 Nov 2021 05:25
Forum: DOS Batch Forum
Topic: How to pipe the outcome of an if-statement to another command?
Replies: 4
Views: 3895

How to pipe the outcome of an if-statement to another command?

I thought I knew quite a lot about Batch and CMD, but the following is puzzling me. ECHO test> 1.txt IF EXIST 1.txt (TYPE 1.txt) ELSE (ECHO test) test (IF EXIST 1.txt (TYPE 1.txt) ELSE (ECHO test)) test So far so good, but I really don't understand why I'm getting... (IF EXIST 1.txt (TYPE 1.txt) ELS...
by Reino
07 Jun 2020 16:05
Forum: DOS Batch Forum
Topic: Batch substring code not working
Replies: 6
Views: 6111

Re: Batch substring code not working

I'm having a hard time figuring out what you're actually trying to do.
What do you want to do with/to "036D9462A58BEE6F0F404BC4A569108B md5.png"?
I understand that the first grep returns "036D9462A5", but then what?
by Reino
01 Jun 2020 15:29
Forum: DOS Batch Forum
Topic: Use 1 variable for all tokens in for-loop
Replies: 2
Views: 3261

Re: Use 1 variable for all tokens in for-loop

I thought /F was always needed to process strings.
I didn't know this. Thanks.
by Reino
01 Jun 2020 09:01
Forum: DOS Batch Forum
Topic: Use 1 variable for all tokens in for-loop
Replies: 2
Views: 3261

Use 1 variable for all tokens in for-loop

My apologies if this has been asked before. 'input.txt' : test1 test2 test3 When you open 'input.txt' (with every string on a new line) in a for-loop (directly, or through a command), it will use the same %A for each line, as expected: FOR /F %A IN (input.txt) DO @ECHO -%A -test1 -test2 -test3 FOR /...
by Reino
13 Jul 2019 05:45
Forum: DOS Batch Forum
Topic: Passing arguments with spaces in it to a subroutine
Replies: 2
Views: 5612

Re: Passing arguments with spaces in it to a subroutine

Thanks a lot for your input, jeb! Passing the variable name as argument is something I would've never come up with. SET json={^^^"a^^^": ^^^"a b c^^^"^^^, ^^^"b^^^": ^^^"x y z^^^"} SETLOCAL ENABLEDELAYEDEXPANSION CALL :Info json ENDLOCAL EXIT /B 0 :Info ECHO !%1! EXIT /B Output: {^"a^": ^"a b c^"^, ...
by Reino
13 Jul 2019 04:24
Forum: DOS Batch Forum
Topic: Passing arguments with spaces in it to a subroutine
Replies: 2
Views: 5612

Passing arguments with spaces in it to a subroutine

Hello, I'm working with JSONs and I'm having trouble correctly passing these JSONs as arguments with spaces in it to a subroutine. The following simple JSON, {"a": 1, "b": 2} , is working fine: SET json={^^^"a^^^": 1^^^, ^^^"b^^^": 2} SETLOCAL ENABLEDELAYEDEXPANSION CALL :Info "!json!" ENDLOCAL EXIT...
by Reino
15 Oct 2016 15:08
Forum: DOS Batch Forum
Topic: How to escape special characters in for-loop?
Replies: 2
Views: 5496

Re: How to escape special characters in for-loop?

I found this old thread of mine and seeing nobody has answered it yet, I might as well do it myself. The reason the for-loop didn't work was because of the single double-quot between the initial double-quotes. It appears there always needs to be a closing double-quot: "replace(replace($raw,':',...
by Reino
28 Jul 2015 11:37
Forum: DOS Batch Forum
Topic: How to escape special characters in for-loop?
Replies: 2
Views: 5496

How to escape special characters in for-loop?

More and more I get the feeling I should start learning a more intuitive language like Python, because I have another issue that needs a workaround. Test script for a valid filename regex: @ECHO off FOR /F "tokens=2 delims=:." %%X IN ('CHCP') DO SET codepage=%%X CHCP 1252>NUL SET "nam...
by Reino
21 Jun 2015 14:23
Forum: DOS Batch Forum
Topic: Exclamationmark in variable causes parsing-errors
Replies: 3
Views: 4206

Re: Exclamationmark in variable causes parsing-errors

Hello jeb, But in your case you activate the delayed expansion a second time by using the ECHO %%A in the line FOR /F "delims=" %%B IN ('ECHO %%A ^| %jq% .') DO ECHO %%B Ah! I didn't know that. We learn everyday. The solution to handle exclamation marks within for-loops is the toggling tec...
by Reino
21 Jun 2015 11:23
Forum: DOS Batch Forum
Topic: Exclamationmark in variable causes parsing-errors
Replies: 3
Views: 4206

Exclamationmark in variable causes parsing-errors

VPWON_1226681.jsonp: parseMetadata({"STATUS":"OK","VERSION":"1.11.13\n","prid":"VPWON_1226681","titel":"De IJzeren Eeuw","aflevering_titel":"Ten oorlog!","info":"Geschiedenisserie over ...
by Reino
25 May 2015 02:21
Forum: DOS Batch Forum
Topic: Newline character as delimiter in for-loop
Replies: 11
Views: 18725

Re: Newline character as delimiter in for-loop

Perhaps that was a little bit harsh, yes.
ShadowThief, thanks for your help too, but I still won't be using temp files. :wink:
by Reino
24 May 2015 17:43
Forum: DOS Batch Forum
Topic: Newline character as delimiter in for-loop
Replies: 11
Views: 18725

Re: Newline character as delimiter in for-loop

I'm sorry, Ed Dyreen. I didn't understand your code at first. @ECHO off SET youtube-dl="youtube-dl.exe" SET "url=https://www.youtube.com/watch?v=KpvLMyC4a8o" SET format=135+141 SETLOCAL ENABLEDELAYEDEXPANSION FOR /F %%A IN ('^"%youtube-dl% --no-warnings -gf %format% "%u...
by Reino
24 May 2015 15:42
Forum: DOS Batch Forum
Topic: Newline character as delimiter in for-loop
Replies: 11
Views: 18725

Re: Newline character as delimiter in for-loop

Sorry, but I refuse to use temp files.