Answer for any Googlers - the issue was not in the passing of the parameters to openssl
, it was in the encoding of the batch file itself.
Once I changed the encoding in my editor (Notepad++) to Windows-1252
, the batch ran the commands with ease and didn't need any special /
-instead-of--
approach.
I don't think it is working as you expect for a non-file list because as indicated within for /?
. . .
FOR /F ["options"] %variable IN (file-set) DO command [command-parameters]
FOR /F ["options"] %variable IN ("string") DO command [command-parameters]
FOR /F ["options"] %variable IN ('command') DO command [command-parameters]
I believe this means the FOR /F
handles either command
, string
, or file-set
which I presume file-set
specifically means an actual file. If this is the case, then that means putting the non-file list within there, it's interpreted as being a string which the delims
and tokens
cannot parse or iterate.
To resolve put the non-file list within a regular for loop without using any tokens
or delims
, and ensure values which contain a space are enclosed with double quotes.
@echo off
cls
for %%G in ("3D Objects",Documents,Downloads,Music,Pictures,Videos) do (
echo %%~G
)
You could put double quotes around all values and use the [~
] tilde in the variable placeholder to parse out the double quotes from the output value giving the desired output without double quotes.
@echo off
cls
for %%G in ("3D Objects","Documents","Downloads","Music","Pictures","Videos") do (
echo %%~G
)
Output
3D Objects
Documents
Downloads
Music
Pictures
Videos
Supporting Resources
Best Answer
Test.txt
is not in the same directory you are running your script from.To better accomplish grabbing just the third line from a text file, try the following, which will run quickly on ANY size file, instead of having to run through an entire file as yours would (and yours would incorrectly... you are actually grabbing every third line).
(for /l %%a in (1,1,3) do set /p LineThree=) < Test.txt
echo %LineThree%
As mentioned in another comment, you might want to try the full path to the file instead of just the file name.