Autocreate Multiple Playlists from Multiple Words in Tags

I created a little tool that uses words in the %comment% Tag to create Playlists, one playlist for ANY word in the %comment% tag.

For example, if you have 2 songs,
A) "Beatles - Yesterday" with the %comment% tag "ballads beatles"
B) "Aerosmith - Dream On" with the %comment% tag "ballads aerosmith"

it will create 3 playlists:

  1. "-ballads-.m3u" containing both songs A and B
  2. "-beatles-.m3u" containing the first song A
  3. "-aerosmith-.m3u" containing the second song B

In addition it will create one playlist for any folder of your files - e.g. if the songs are stored in a directory "My Songs", there will be an additional m3u file named "-ZZD-MySongs-.m3u.

Details:
DESCRIPTION:
This tool creates playlists
a) for all blank separated words in the %comment% tag (multiple words = multiple playlists)
b) for all subfolders in your Music Folder (one playlist for each subfolder)

The created playlists are named -{Playlistname}-.m3u (for blank separated words in the %comment% tag)
The created playlists are named {DirectoryPrefix}-{foldername}-.m3u (for all subfolders).

They are stored in the folder \playlists (in the main music folder). The playlists reference filepaths relative to \playlist.

NOTES:

  • The %comment% tag will be used to create playlists for each blank separated word in each %comment% tag
  • make sure that the %comment% tag contains only words for which you want to create playlists!

INSTRUCTIONS:

  1. Create an Export configuration in MP3Tag with the tool commands
  2. Delete all content in the %comment% tags; create words in the %comment% tags for which you want to have playlists (e.g. by genre: %comment%="rock pop" will create one playlist for "rock" and one for "pop")
  3. Highlight the files for which you want to create the playlists
  4. Use the export function in MP3Tag to run. This will create the file "create_mp3_lists.bat" in the \playlists folder
  5. MP3Tag will ask you to view the exported file. Confirm. The "create_mp3_lists.bat" will open in a new window.
  6. Confirm again. The file "create_mp3_lists.bat" will delete all old "-*-.m3u" playlists and create all new playlists.

TIP: Create Actions in order to append Standard Words into the %comment% field, e.g. Format "Comment": %comment% jazz

BELOW is the Export Configuration File. It will create a batch file that in turn creates the playlists.
DISCLAIMER: Use this completely at your own risk. Do backups before usage. I provide this "as is" without any warranties, service or anything else. I tested it on several computers, however, it might need amendment on yours ...
Cheers...

$filename(.\playlists\create_mp3_lists.bat,ansi)@ECHO OFF
$puts(REM,*********** This marks a mp3tag remark)
REM ***************** This marks a batch file remark
$puts(DirectoryPrefix,-ZZD)$puts(REM,*********** Setting the prefix for the directory)
REM **************************************************************************
REM ***************** Generated by %_app% on %_datetime%
ECHO ****************************************************************************************************************
ECHO MP3Tag: Automatically create playlists based on folders and tags - Written by Nashquick
ECHO         Based on ideas of Moonbase
ECHO. 
ECHO DESCRIPTION:
ECHO    This tool creates playlists 
ECHO       a) for all blank separated words in the '%comment%' tag (multiple words = multiple playlists)
ECHO       b) for all subfolders in your Music Folder (one playlist for each subdirectory)
ECHO    The created playlists are named "-{Playlistname}-.m3u" (for blank separated words in the '%comment%' tag)
ECHO    The created playlists are named "{DirectoryPrefix}-{foldername}-.m3u" (for all subfolders).
ECHO    They are stored in the folder \playlists (in the main music folder). The playlists reference filepaths relative to \playlist.
ECHO.
ECHO NOTES: 
ECHO    - The '%%comment%%' tag will be used to create playlists for *each* blank separated word in each '%comment%' tag 
ECHO         - make sure that the '%comment%' tag contains only words for which you want to create playlists!
ECHO.
ECHO INSTRUCTIONS:
ECHO    1) Create an Exportconfiguration in MP3Tag with the tool commands
ECHO    2) Delete all content in the '%comment%' tags; create words in the '%%comment%%' tags for which you want to have playlists 
ECHO          (e.g. by genre: '%comment%'="rock pop" will create one playlist for "rock" and one for "pop")
ECHO    3) Highlight the files for which you want to create the playlists
ECHO    4) Use the export function in MP3Tag to run. This will create the file "create_mp3_lists.bat" in the \playlists folder
ECHO    5) MP3Tag will ask you to view the exported file. Confirm. The "create_mp3_lists.bat" will open in a new window. 
ECHO    6) Confirm again. The file create_mp3_lists.bat will delete all "-*-.m3u" playlists and then will create all playlists.
ECHO	TIP: Create Actions in order to append Standard Words into the %comment% field, e.g. Format "Comment": %comment% jazz
ECHO.
ECHO ****************************************************************************************************************
ECHO Start to create playlists for all folders and for all blank-separated words in the '%comment%' tag
ECHO IF YOU CONTINUE, ALL OLD PLAYLISTS WITH THE NAME "-*-.m3u" IN THE FOLDER \playlists WILL BE DELETED!'
Pause 
ECHO.
ECHO.
SETLOCAL
SET PlaylistPath=..\playlists\
SET PrefixForDirectiory=^'$get(DirectoryPrefix)
ECHO Removing old ..\playlists\-*-.m3u files / playlists ...
DEL /Q "%PlaylistPath%-*-.m3u"
ECHO complete.
ECHO.
$loop(%_path%)$puts(REM,*********** Move through all files)
$puts(REM,------------------------------------------------------------------------------------------)
$puts(MainFolder,$cutRight(%_workingpath%,1))$puts(REM,-----sets the filename for the main mp3 folder)
$puts(REM,------------------------------------------------------------------------------------------)
$puts(FileInfo,$replace($if(%artist%%title%,%artist% - %title%,%_filename%),'^','^^','-','^-','%','%%','(','^(','[','^[','/','^/','<','^<','|','^|','>','^>','"','^"','&','^&',']','^]','{','^{','}','^}',')','^)',',','^,','$','^$'))$puts(REM,*********** sets the fileinfo for the playlist)
$puts(RelFilePath,$replace(..$cutLeft(%_path%,$len($get(MainFolder))),'^','^^','-','^-','%','%%','(','^(','[','^[','/','^/','<','^<','|','^|','>','^>','"','^"','&','^&',']','^]','{','^{','}','^}',')','^)',',','^,','$','^$'))$puts(REM,***********sets the relative filepath for the playlist)
$puts(FileComment,$trim($replace($replace($replace($replace($replace($replace($replace($replace(%comment%,  , ),  , ),  , ),  , ),  , ),  , ),  , ),  , )))$puts(REM,***********trims Comment field and strips from up to 255 multi-blanks)
ECHO Creating playlistentries for $get(RelFilePath) '...'
SET FilenameForFolder="'%'PlaylistPath'%''%'PrefixForDirectiory'%'$cutLeft($replace(%_folderpath%,\,-),$len($get(MainFolder))).m3u"$puts(REM,***********sets the filename for the directiory playlist)
$puts(REM,**************************create playlist entry for folder)
ECHO ^#EXTINF:%_length_seconds%'^,'$get(FileInfo) >>'%'FilenameForFolder'%'
ECHO $get(RelFilePath)>>'%'FilenameForFolder'%'
$puts(REM,**************************create playlist entry for all comment entries)
SET CommentEntry="'%'PlaylistPath'%'-$replace($get(FileComment), ,-.m3u"
ECHO ^#EXTINF:%_length_seconds%'^,'$get(FileInfo) >>'%'CommentEntry'%'
ECHO $get(RelFilePath)>>'%'CommentEntry'%'
SET CommentEntry="'%'PlaylistPath'%'-)-.m3u"
ECHO ^#EXTINF:%_length_seconds%'^,'$get(FileInfo) >>'%'CommentEntry'%'
ECHO $get(RelFilePath)>>'%'CommentEntry'%'
$loopend()
$puts(REM,**************************Create playlist header entry)
'ECHO.'
'ECHO Creating playlists header entries ...'
'FOR %%f IN ("%PlaylistPath%-*-.m3u") DO ('
'ECHO #EXTM3U'
'TYPE "%%f")>"%%f.tmp"'


'DEL /Q "%PlaylistPath%-*-.m3u"'
'REN "%PlaylistPath%-*-.m3u.tmp" "*."'
SET FilenameForFolder=
SET PlaylistPath=
SET CommentEntry=
SET FileTemp=
ENDLOCAL
ECHO Done. Enjoy listening.
Pause