Here is a simple script that creates an .m3u playlist file via the Explorer shell menu. If the user right-clicks on a folder, it will create an m3u list based on the audio files inside that folder. If the user right-clicks on a file, it will create an m3u list based on audio files that reside in the files current directory.
This script can be installed uncompiled by specifying the path to AutoHotkey.exe in the command line. Sample registry keys required to link it to the shell menu are posted below along with the source code.
Recognised audio formats:
WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA
Changelog:
* updated to write full path to audio files in m3u file
* updated to work with a wide range of audio formats
* updated to only create an m3u file if audio files exist in current directory
* script updated to get path details from clicked-on item
* script now titles the created .m3u file with the name of the directory it was created in
Code:
splitpath, 1, file, dir
filegetattrib, attr, %1%
if attr contains D ; launched from a directory
{
m3u = %dir%\%file%\%file%.m3u
loop, %dir%\%file%\*.*
{
splitpath, A_LoopFileName, , , ext
if ext in WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA
{
filelist = %filelist%%A_LoopFileLongPath%`n
count++
}
}
if count = ; no audio files found
return
sort, filelist
filedelete, %m3u%
fileappend, #EXTM3U`n%filelist%, %m3u%
}
else ; launched from a file
{
; get the current folder for the m3u name:
stringsplit, array, dir, \
folder := array%array0%
m3u = %dir%\%folder%.m3u
loop, %dir%\*.*
{
splitpath, A_LoopFileName, , , ext
if ext in WAV,AIFF,AIF,IFF,SVX,SND,AU,VOC,CUE,OGG,MPC,MP+,MPP,MP3,MP2,MP4,M4A,AAC,FLAC,FLA,APE,MAC,WV,SPX,SID,CDA
{
filelist = %filelist%%A_LoopFileLongPath%`n
count++
}
}
if count = ; no audio files found
return
sort, filelist
filedelete, %m3u%
fileappend, #EXTM3U`n%filelist%, %m3u%
}
return
Compiled:
Code:
REGEDIT4
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create Playlist"
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist\command]
@="\"x:\\path to exe\\create m3u.exe\" \"%1\""
Uncompiled:
Code:
REGEDIT4
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist]
@="Create Playlist"
[HKEY_CLASSES_ROOT\AllFileSystemObjects\shell\Create Playlist\command]
@="\"C:\\Program Files\\AutoHotkey\\AutoHotkey.exe\" \"x:\\create playlist.ahk\" \"%1\""