Search found 20 matches

by Reino
07 Jun 2020 16:05
Forum: DOS Batch Forum
Topic: Batch substring code not working
Replies: 6
Views: 887

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

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

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

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

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

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

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

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

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

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

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

Re: Newline character as delimiter in for-loop

Sorry, but I refuse to use temp files.
by Reino
24 May 2015 14:27
Forum: DOS Batch Forum
Topic: Newline character as delimiter in for-loop
Replies: 11
Views: 9382

Re: Newline character as delimiter in for-loop

This isn't about ignoring lines with eol=x, but the other way around, so I can't use your code. I want to create a singleline of youtube-dl's multiline output, by using CRLF as a delimiter, so I can "tokenize" it into 2 variables. You're saying I can't? I've tried... FOR /F "tokens=1,...
by Reino
24 May 2015 07:18
Forum: DOS Batch Forum
Topic: Newline character as delimiter in for-loop
Replies: 11
Views: 9382

Newline character as delimiter in for-loop

I have the following situation: youtube-dl.exe -gf 135+141 https://www.youtube.com/watch?v=KpvLMyC4a8o https://r3---sn-mn4vg5aa-5hns.googlevideo.com/...longurl... https://r3---sn-mn4vg5aa-5hns.googlevideo.com/...longurl... When you want youtube-dl to return the videolink of 2 formats of a certain vi...
by Reino
18 May 2015 08:17
Forum: DOS Batch Forum
Topic: Pipe in for loop breaks double quoted variables
Replies: 11
Views: 4897

Re: Pipe in for loop breaks double quoted variables

CMD /C only strips the outer quotes if the very first character is a quote. So I simply put an extra space before the command. SET curl="C:\map with spaces\curl.exe" SET jq="C:\map with spaces\jq-1.5rc1.exe" ... FOR %%A IN ("%url%") DO ( FOR /F "delims=" %%B ...