Generate a M3U file per folder

Tag(s):

REM Description: Generate a M3U file per folder.
REM   -You need to change "C:\Your\MP3\folder\path\" to match your folder path.
REM   -Multilingual is limited by DIR command.
REM Requirements: -You need SED installed.
 
FOR /R "C:\Your\MP3\folder\path\" %%G IN (.) DO (
CALL :Create_M3U "%%G"
)
ECHO "Other commands here after the loop."
 
GOTO :EOF
 
:Create_M3U
  PUSHD %1

  REM Format the directory name.
  ECHO %1 > tmpfile.txt
  sed -i "s/\\\.//" tmpfile.txt
  sed -i "s/.*\\//" tmpfile.txt
    REM Clean up directory name.
    sed -i "s/ //g" tmpfile.txt
    sed -i "s/-//g" tmpfile.txt
    sed -i "s/,//g" tmpfile.txt

  REM Assign directory name to a variable to be used.
  sed -i "s/$/\.m3u/g" tmpfile.txt
  SET /p m3uFilename= < tmpFile.txt

  REM Create M3U file with a list of *.mp3
  ECHO #EXTM3U > %m3uFilename%
  REM DIR /s/b/o *.mp3 >> %m3uFilename%
  CALL relative_file_path.bat | find /i ".mp3" >> %m3uFilename%

  REM Add absolute directory path to MP3 filename
  REM sed -i "s/^/%1/" %m3uFilename%
  
  REM Clean up
  DEL /q tmpfile.txt
  DEL /q sed??????
  POPD
 
  GOTO :EOF