Search found 23 matches
- 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: 5876
Re: How to pipe the outcome of an if-statement to another command?
That's some weird stuff, but it works. Thanks, jeb!
- 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: 5876
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.
Thanks for your quick reply.
- 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: 5876
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...
- 07 Jun 2020 16:05
- Forum: DOS Batch Forum
- Topic: Batch substring code not working
- Replies: 6
- Views: 7179
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?
What do you want to do with/to "036D9462A58BEE6F0F404BC4A569108B md5.png"?
I understand that the first grep returns "036D9462A5", but then what?
- 01 Jun 2020 15:29
- Forum: DOS Batch Forum
- Topic: Use 1 variable for all tokens in for-loop
- Replies: 2
- Views: 3799
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.
I didn't know this. Thanks.
- 01 Jun 2020 09:01
- Forum: DOS Batch Forum
- Topic: Use 1 variable for all tokens in for-loop
- Replies: 2
- Views: 3799
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 /...
- 13 Jul 2019 05:45
- Forum: DOS Batch Forum
- Topic: Passing arguments with spaces in it to a subroutine
- Replies: 2
- Views: 6107
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^"^, ...
- 13 Jul 2019 04:24
- Forum: DOS Batch Forum
- Topic: Passing arguments with spaces in it to a subroutine
- Replies: 2
- Views: 6107
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...
- 15 Oct 2016 15:08
- Forum: DOS Batch Forum
- Topic: How to escape special characters in for-loop?
- Replies: 2
- Views: 6276
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,':',...
- 28 Jul 2015 11:37
- Forum: DOS Batch Forum
- Topic: How to escape special characters in for-loop?
- Replies: 2
- Views: 6276
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...
- 21 Jun 2015 14:23
- Forum: DOS Batch Forum
- Topic: Exclamationmark in variable causes parsing-errors
- Replies: 3
- Views: 4708
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...
- 21 Jun 2015 11:23
- Forum: DOS Batch Forum
- Topic: Exclamationmark in variable causes parsing-errors
- Replies: 3
- Views: 4708
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 ...
- 25 May 2015 02:21
- Forum: DOS Batch Forum
- Topic: Newline character as delimiter in for-loop
- Replies: 11
- Views: 20777
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.
ShadowThief, thanks for your help too, but I still won't be using temp files.
- 24 May 2015 17:43
- Forum: DOS Batch Forum
- Topic: Newline character as delimiter in for-loop
- Replies: 11
- Views: 20777
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...
- 24 May 2015 15:42
- Forum: DOS Batch Forum
- Topic: Newline character as delimiter in for-loop
- Replies: 11
- Views: 20777
Re: Newline character as delimiter in for-loop
Sorry, but I refuse to use temp files.