Some files include the ampersand symbol. I am trying to take those prompted choices
(from a larger numbered list) and write them into a m3u file, which can be played by Windows
Media player, using the Start command. This works but it bombs when a file name
has the & symbol.
This code illustrates the problem--it is my attempt to find a solution to the ampersand in text.
I have no clue if usebackq should be part of the solution.
Thanks.
Code: Select all
@echo off
setlocal enabledelayedexpansion
Set "fileName=Black & White Rag.mid"
Call:writeM3U "%fileName%"
Type mplay.m3u
endlocal & exit /b
:writeM3U
setlocal enabledelayedexpansion
For /F "usebackq" %%a In ('%~1') Do (
Set "mVar=%%a"
)
endlocal & echo %mVar%>mplay.m3u
exit /b
The error is:
& was unexpected at this time.
C:\Temp\>For /F "usebackq" %a In ('Black & White Rag.mid') Do (