Constant string in dynamic batch script
<p>I have a batch script (-> <a href="https://stackoverflow.com/questions/22401214/windows-batch-bat-automatic-m3u-playlist-creation-update">windows batch .bat automatic .m3u playlist creation / update</a> ) to automatically generate playlists. These playlists are saved in a subfolder of the rootdir (see code).
So the problem is, that the subfolder is not taken into account in the playlist, so the music files cannot be found. I get </p>

<pre><code>#EXTINF:???,The Realm Of Orzamar
Dragon Age Origins\The Realm Of Orzamar.mp3
</code></pre>

<p>I need </p>

<pre><code>#EXTINF:???,The Realm Of Orzamar
../Dragon Age Origins\The Realm Of Orzamar.mp3
</code></pre>

<p>And with something like</p>

<pre><code>SET "location='.../' + %%c"
</code></pre>

<p>I get </p>

<pre><code>#EXTINF:???,The Realm Of Orzamar
:\music\Dragon Age Origins\The Realm Of Orzamar.mp3
</code></pre>

<p>How can I put this <code>.../</code> string into <code>SET "location=%%c"</code> so it won't be converted to <code>music\</code> . An absolut path is not quite a solution since the filestructure is placed on a portable drive and should work independant and out of the folder root, so for use on Android devices and on any other device with different absolut full paths.
I am unexperienced with batch, just did some very basic stuff so far, I don't really understand this script since I don't know batch syntax.</p>

<p>Thanks in advance.</p>

<p>Code: </p>

<pre><code>CHCP 1252
@ECHO Off
SETLOCAL

:: make a tempfile
:maketemp
SET "tempfile=%temp%\%random%"
IF EXIST "%tempfile%*" (GOTO maketemp) ELSE (ECHO.&gt;"%tempfile%a")



:: Need the start of the tree to scan
SET "rootdir=H:\music"
&gt;"%tempfile%b" (ECHO(%rootdir%&amp;ECHO(*)
FOR /f "delims=:" %%a IN ('FINDSTR /o /L "*" "%tempfile%b"') DO SET /a len=%%a-1

SET "destfile=%~1"

:loop
SHIFT
SET nextdir=%~1
IF NOT DEFINED nextdir GOTO process
IF %nextdir:~0,1%==\ (
 PUSHD "%~1"
 FOR /f "delims=" %%a IN ('dir /b /s /a-d *.mp3 *.mp4 *.ogg *.m4a *.wma *.flac *.wav') DO &gt;&gt;"%tempfile%a" ECHO(%%~na:2:%%a
) else (
 PUSHD "%rootdir%\%~1"
 FOR /f "delims=" %%a IN ('dir /b /s /a-d *.mp3 *.mp4 *.ogg *.m4a *.wma *.flac *.wav') DO &gt;&gt;"%tempfile%a" ECHO(%%~na:%len%:%%a
)
POPD 
GOTO loop

:process
&gt;%destfile% ECHO(#EXTM3U
(
FOR /f "tokens=1,2*delims=:" %%a IN ('SORT "%tempfile%a"') DO (
 ECHO(#EXTINF:???,%%a
 SET "location=%%c"
 SETLOCAL enabledelayedexpansion
  ECHO(!location:~%%b!
 endlocal
)
)&gt;&gt;%destfile%

 del "%tempfile%*"


GOTO :EOF
</code></pre>