Hello. I search the forums, and found a simular question, but the user was wanting a dropplet. I’m trying to use my applescript as a folder action.
on adding folder items to this_folder after receiving added_items
do shell script "~/Movies/vx8300/Temp/ffmpeg -i " & this_name & " ~/Movies/vx8300/Ready/" & this_name & ".mp3"
end adding folder items to
I attach this script to the folder, but when I move a file into the folder, nothing happens. If I replace this_name with the actual file name and paths, it does work. But of course, the filenames vary, so I need something that isnt hard coded.
Im new to applescript. Is there anyone willing to help me with this?
Ryan
Model: Mac Mini PPC
AppleScript: 1.10.7
Browser: Firefox 2.0b2
Operating System: Mac OS X (10.4)
You need to find the variable ‘this_name’ used by the shell script for each file added. This needs to be a slash delimited path for the shell script to work.
You can add more than one file to a folder at a time. The variable ‘added_items’ contains a list of the file paths to the files that are in the process of being added. You need to loop through the items in the list ‘added_items’ and get their POSIX paths.
on adding folder items to this_folder after receiving added_items
-- Loop through the file references.
repeat with this_item in added_items
-- Get the POSIX path of the file being referenced.
set this_name to POSIX path of this_item
-- Do your shell script. Quote the file paths i case of file names with spaces.
do shell script "ffmpeg -i " & quoted form of (this_name) & " " & quoted form of ("~/Movies/vx8300/Ready/" & this_name & ".mp3")
end repeat
end adding folder items to
You might also want to set up some error checking for files of the wrong type etc.