- Jul
- 532
- 10
UNIMPORTANT BACKSTORY: So, I’m passing a filename to a subroutine that creates a BAT file [to be run once]. The filename has percent signs in it -- ugh. After an hour of fussing with setdos, which needs to be x-3 in some situations, x-4 in others.... I successfully achieve the goal of getting the % sign properly represented in the generated bat file.
THE REAL PROBLEM:
I have a (generated) BAT file that looks like this:
So here’s the problem.
If i use setdos /x-4 before calling get-lyrics, the percent is missing! Because it evaluated it as a nested environment variable, even though it’s not an environment variable that exists:
call get-lyrics "18_60 (Reprise).mp3"
But if i use setdos /x-3 before calling get-lyrics, it doesn’t expand the environment variable to the filename at all:
call get-lyrics %file%
So:
/x-3 - stop all var expansion - is too little expansion: it prevents %file from expanding
/x-4 - stop NEXTED expansion - is too much expansion - %file is expanded, but it tries to expand percent signs in the filename.
How how how how how can I deal with this situation? I’m stuck.
My spouse wants me to get away from the computer.
Meanwhile I’m over here like "What I need is setdos /x- 3-and-a-half"
THE REAL PROBLEM:
I have a (generated) BAT file that looks like this:
Code:
@Echo on
@setdos /x-4
rem This setdos /x-4 makes the % in the filename successfully pass to the process subroutine
gosub process "18_60% (Reprise).mp3"
goto :skip_subs
:process [file]
setdos /x-4
echo call get-lyrics %file% I AM DOING JUST-THE-ECHO UNTIL IT WORKS RIGHT
rem call get-lyrics %file% CAN’T ACTUALLY DO IT UNTIL IT WORKS RIGHT
setdos /x0
return
:skip_subs
@setdos /x0
:END
So here’s the problem.
If i use setdos /x-4 before calling get-lyrics, the percent is missing! Because it evaluated it as a nested environment variable, even though it’s not an environment variable that exists:
call get-lyrics "18_60 (Reprise).mp3"
But if i use setdos /x-3 before calling get-lyrics, it doesn’t expand the environment variable to the filename at all:
call get-lyrics %file%
So:
/x-3 - stop all var expansion - is too little expansion: it prevents %file from expanding
/x-4 - stop NEXTED expansion - is too much expansion - %file is expanded, but it tries to expand percent signs in the filename.
How how how how how can I deal with this situation? I’m stuck.
My spouse wants me to get away from the computer.
Meanwhile I’m over here like "What I need is setdos /x- 3-and-a-half"