Hi All.
I want to setup a folder action which will watch a specified folder. When new items appear in the folder in this case flac files they will the be opened by XLD which will inturn convert them to mp3 files for me.
So what I have at the moment is the following.
on adding folder items to this_folder after receiving added_items
tell application "Finder"
set theFiles to every file of entire contents of theFolder
repeat with i from 1 to count of theFiles
set thisFile to item i of theFiles as alias
tell application "Finder" to open thisFile
end repeat
end tell
end adding folder items to
At the moment this just looks at what ever files are in the root of the folder I am performing the folder action on. I want to to look into subfolders and I also want it to only open files that have an extension of *.flac.
At the moment the folder action does not seem to do anything, although when I change the script so I can select the folder with the flac files it does run as I want except it opens all files in the folder and not just flak’s.
Any help would be appreciated.
Hi,
folder actions respond only to the top level of the attached folder, not to any subfolders.
A workaround is to drop all files onto the hot folder, process them and move them to the appropriate subfolders
To process only the new items use something like this
on adding folder items to this_folder after receiving added_items
repeat with anItem in added_items
tell application "Finder" to open anItem
end repeat
end adding folder items to
PS: Your script doesn’t work at all because there is no defined variable theFolder
I’ve never found Folder Actions to be very reliable. Noodlesoft has a preference pane called “Hazel” that will do what a Folder Action can do and much more. $22. Worth looking into if you intend to rely on this.
Thanks for that. It helped.
What I ended up doing if any one is interested was I turned this into two folder actions. I created one folder that had the following run
on adding folder items to this_folder after receiving added_items
do shell script "/Library/Scripts/Folder\\ Action\\ Scripts/find\\ -\\ flac.sh"
end adding folder items to
the shells script it references is the following
find ~/Desktop/temp -iname *.flac -print0 | while IFS= read -r -d ‘’ file; do cp “$file” ~/Desktop/flac; done
Which then copied it into my second file that would then open the files with XLD which would then convert them to mp3 and dump them were ever I want them to.
The reason I was after this was so I could rip my cd collection to flac as and have the traces automatically converted to mp3 to work with iTunes. The other reason being so that if I download any music usually flacs my downloads folder will be checked and those files automatically converted into mp3’s and stored were I need them to be.