How may I escape embedded ! characters in the value of a variable PL used in delayed expansion !PL!, such that they are not interpreted as delimiters?
E.g. to remedy the failure of this when %%P contains ! .
FOR %%P IN (%input%\*.M3U) DO (
echo Processing playlist "%%P"
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=*" %%L IN ('type "%%P"') DO (
SET PL=%%~pP%%L
echo Processing reference "!PL!"
)
ENDLOCAL
)
EDIT: Paul's limited-applicability workaround:
FOR %%P IN (%input%\*.M3U) DO (
echo Processing playlist "%%P"
FOR /F "tokens=*" %%L IN ('type "%%P"') DO (
SET PL=%%~pP%%L
SETLOCAL ENABLEDELAYEDEXPANSION
echo Processing reference "!PL!"
ENDLOCAL
)
)