What file type to listen to music?
Reply #19 – 2012-05-22 22:49:35
droplet a. extracts metadata from any lossy or lossless file to some sort of textual ini file droplet b. owerwrites an existing metadata with one found externally with the same name - extension Stealing this idea, I've just written a little applescript to extract some meaningful metadata from every track contained in an iTunes user playlist named "Tag Export" and write a plain text file with the same name of the original track file and a .tags extension, made of TAGNAME=VALUE lines (suitable to use for example with metaflac --import-tags-from=FILE). It asks for a starting directory and recreates the same two level directory structure "CD/Track" I use to archive my files, but it shouldn't be too difficult to modify for nesting at n levels. It can be used periodically because it rewrites already saved files from same track at same position. It's my very first attempt with this scripting language, so it's rather basic, nothing more than a proof of concept. Anyway it seems to work and if someone finds it useful, feel free to use and alter it at your will and peril. Of course it's provided "as is", no warranty whatsoever and all the usual stuff for free code.tell application "Finder" set baseFolder to (choose folder with prompt "Select output folder:") as string end tell set totalTracks to 0 set CR to ASCII character 10 tell application "iTunes" repeat with currTrack in tracks of user playlist "Tag Export" set tagList to "ALBUM=" & album of currTrack & CR set tagList to tagList & "COMPOSER=" & composer of currTrack & CR set tagList to tagList & "TITLE=" & name of currTrack & CR set tagList to tagList & "ARTIST=" & artist of currTrack & CR set tagList to tagList & "ALBUMARTIST=" & album artist of currTrack & CR set tagList to tagList & "GROUPING=" & grouping of currTrack & CR set tagList to tagList & "COMPILATION=" & compilation of currTrack & CR set tagList to tagList & "GENRE=" & genre of currTrack & CR set tagList to tagList & "YEAR=" & year of currTrack & CR set tagList to tagList & "TRACKNUMBER=" & track number of currTrack & CR set tagList to tagList & "TRACKTOTAL=" & track count of currTrack & CR set tagList to tagList & "DISCNUMBER=" & disc number of currTrack & CR set tagList to tagList & "DISCTOTAL=" & disc count of currTrack & CR set tagList to tagList & "COMMENT=" & comment of currTrack & CR set stDel to AppleScript's text item delimiters try set AppleScript's text item delimiters to ":" set pathLevels to the text items of (location of currTrack as string) set discFolder to item ((count of pathLevels) - 1) of pathLevels set trackFile to last item of pathLevels set AppleScript's text item delimiters to "." set trackName to the first item of (text items of trackFile) set AppleScript's text item delimiters to stDel on error set AppleScript's text item delimiters to stDel end try set discFolder to item ((count of pathLevels) - 1) of pathLevels set fullPath to baseFolder & discFolder tell application "Finder" if not (exists folder fullPath) then make new folder at baseFolder with properties {name:discFolder} end if set outFileName to fullPath & ":" & trackName & ".tags" if exists file outFileName then delete file outFileName end if set fileRefr to (a reference to (open for access outFileName with write permission)) write tagList to fileRefr close access fileRefr end tell set totalTracks to totalTracks + 1 end repeat display dialog (totalTracks as string) & " files written" buttons {"OK"} default button 1 end tell