PDA

View Full Version : add files to iTunes playlist with folder action




aendaman
Sep 28, 2008, 04:44 AM
hi,

i try to write an apple script to use as folder action which, when copying files to that folder will adds them to a specific itunes playlist and set them bookmarkable.

so far i put this together from snippets i found:


property DELAY_TIME_SECONDS : 5 -- How long to wait between checking file size.

on adding folder items to my_folder after receiving the_files

repeat with i from 1 to number of items in the_files
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, it means the copy is complete because the size hasn't changed.
repeat while newSize is not equal to oldSize
-- Get the file size.
set oldSize to size of (info for i)
delay DELAY_TIME_SECONDS
-- Sample the size again after delay for comparison.
set newSize to size of (info for i)
end repeat

tell application "iTunes"
launch
try
set this_file to (item i of the_files)
add this_file to playlist "test"
set bookmarkable of this_file to true

end try
end tell
end repeat
end adding folder items to


i compiled and saved it in ~/Library/Scripts/Folder Action Scripts then added it to the folder as folder action but when i drop a file into the folder, nothing happens in iTunes.

any help appreciated



motulist
Sep 28, 2008, 05:11 AM
Very industrious of you, but you could've saved yourself a lot of time and effort by googling first. Google is your friend. Unless you already googled and couldn't find what you want, in which case nevermind.

http://www.google.com/search?num=100&hl=en&client=safari&rls=en-us&q=%22folder+action%22+itunes+playlist&btnG=Search