osx - Applescript Folder Action not working -
osx - Applescript Folder Action not working -
i wrote applescript monitor folder new input. on receiving new item, open itunes, create playlist , add together new files playlist. however, when attach script folder action via folder action setup , add together new item, nil happens. have placed script within /library/scripts/folder action scripts ~/library/scripts/folder action scripts still doesn't fire. here code below:
global album_name global artist_album on adding folder items this_folder after receiving added_items --get name of added folder repeat x in added_items re-create name of x string playlist_name set applescript's text item delimeters "-" set delimited_playlist_name every text item of playlist_name set artist_name text item 1 of delimited_playlist_name set album_name text item 2 of delimited_playlist_name set applescript's text item delimeters "" end repeat tell "finder" activate "itunes" tell application "itunes" if not (exists playlist album_name) --make itunes playlist create playlist properties {name:album_name} --add tracks itunes playlist repeat song in playlist_name add together song playlist album_name set album of song album_name set artist of song artist_name set comment of song "" set composer of song "" set grouping of song "" set description of song "" set long description of song "" set (volume adjustment) of song 100 end repeat set view of browser window album_name end if end tell end adding folder items
i'm running mac os 10.8.4
in future
test code in applescript editor, helps a lot :) if dont utilize applescript editor, useful messages, utilizedisplay dialog
entries throughout code see how far goes , going on. so, assuming problem code, rewrote simple applescript , got work on snow leopard (10.6.8) system.
it runs ok within automator folder action code in run applescript action item. 1 time saved within automator did activate when new files added folder , run ok.
ps: since didn't provide details, had guesstimate code trying do. far optimal going...
hth
# remove line applscript action in automator... set input (choose file multiple selections allowed) set playlist_name {} #display dialog "delimeter set -" set applescript's text item delimiters "-" repeat x in input #display dialog "item: " & (x text) tell application "finder" set fl name of x display dialog "filename: " & fl end tell # bring focus editor ## testing activate me # append item list re-create (fl text) end of playlist_name display dialog "playlist count: " & length of playlist_name set artist_name text item 1 of fl display dialog "artist: " & artist_name set album_name text item 2 of fl display dialog "album: " & album_name end repeat #display dialog "activating itunes..." #activate "itunes" #display dialog "itunes activated!" tell application "itunes" if not (exists playlist album_name) display dialog "making new playlist: " & album_name create playlist properties {name:album_name} display dialog "changing view..." set view of browser window 1 playlist album_name # add together tracks itunes playlist repeat song in input display dialog "adding: " & song set newtrack (add song playlist album_name) set album of newtrack album_name set artist of newtrack artist_name set comment of newtrack "" set composer of newtrack "" set grouping of newtrack "" set description of newtrack "" set long description of newtrack "" set (volume adjustment) of newtrack 100 end repeat else display dialog "itunes playlist exists!" end if end tell
osx applescript
Comments
Post a Comment