Build a new computer and had to transfer my MP3 collection to a different drive. Thus, all M3U shortcuts in my Start Menu were now pointing to an incorrect drive letter. solution: Use KiXtart to recreate the shortcuts :-)
And here's the result:
Code:
; Create shortcut hierarchy for M3U files from an MP3 collection
;
; M3U files are stored inside the MP3s folder in the following structure:
; drive:\MP3s\<ARTIST>\<ALBUM>\<some_playlist_name>.M3U
;
; The script will create a main folder "Music" in the user's Start Menu, then a
; subfolder for each artist, followed by shortcuts to each of the albums
; with the shortcut labeled as the album and pointing to the actual M3U file
;
; The "_" underscore character is automatically removed from all Artist and Album names
;
; Author: Jens Meyer
;
; Dependencies: DirPlus(), WSHShortCut()
break on
dim $iRC
$iRC=setoption('Explicit','on')
$iRC=setoption('NoVarsInStrings','on')
$iRC=setoption('NoMacrosInStrings','on')
dim $sMP3Dir, $sShortcutDir, $bRebuild
dim $sShortcutName, $sTargetPath, $sDescription
dim $aoM3UFiles, $oM3UFile, $asM3UFile
dim $sArtist, $sAlbum, $iAlbumsAdded, $iArtistsAdded
; source directory for the MP3 collection accordign tot he file structure outlined above
$sMP3Dir='c:\wutemp\aa\'
; target directory for the shortcuts
$sShortcutDir='%USERPROFILE%\Start Menu\Music'
; counters indicating whether artists/albums have been added
$iArtistsAdded=0
$iAlbumsAdded=0
; boolean flag (0=add only new shortcuts, otherwise rebuild all shortcuts)
$bRebuild=1
? 'M3U Shortcut Creator v1.0'
? 'Scan source directory for M3U files...'
; find all M3U files
$aoM3UFiles=dirplus($sMP3Dir,'/S /F M3U')
'done'
if ubound($aoM3UFiles)=-1
? 'No M3U files found'
else
? 'Found '+(ubound($aoM3UFiles)+1)' albums'
; delete existing shortcut folder if rebuilding shortcuts
if not $bRebuild=0 and exist($sShortcutDir)
? 'Deleting existing Music directory'
shell '%COMSPEC% /C RD /S /Q "'+$sShortcutDir+'"'
endif
; create main shortcut directory if it does not yet exist
if not exist($sShortcutDir)
? 'Creating Music directory'
md $sShortcutDir
endif
for each $oM3UFile in $aoM3UFiles
$asM3UFile=split($oM3UFile,'\')
$sArtist=trim(join(split($asM3UFile[ubound($asM3UFile)-2],'_'),''))
$sAlbum=trim(join(split($asM3UFile[ubound($asM3UFile)-1],'_'),''))
$sShortcutName=$sShortcutDir+'\'+$sArtist+'\'+$sAlbum
$sTargetPath=$oM3UFile
$sDescription=$sArtist+' - '+$sAlbum
; create the artist dir if it doesn't yet exist
if not exist($sShortcutDir+'\'+$sArtist)
md $sShortcutDir+'\'+$sArtist
$iArtistsAdded=$iArtistsAdded+1
endif
; create the shortcut if it doesn't yet exist
if not exist($sShortcutName+'.lnk')
if $iAlbumsAdded=0
? 'Adding new albums'
endif
$iRc=wshshortcut($sShortcutName,$sTargetPath,,,,,$sDescription)
? $sDescription
$iAlbumsAdded=$iAlbumsAdded+1
endif
next
endif
if $iAlbumsAdded=0
? 'No new albums added'
else
? 'Added '+$iArtistsAdded+' artists and '+$iAlbumsAdded+' albums'
endif
exit 0