Checking folder actions and shell commands

Hi Everyone,

I am trying to make a script that is used by folder actions and calls an ffmpeg shell command. So I have a folder called “MPEG” on my desktop. When a file is dragged into that folder, I want the script to run. I am then trying to pull the filename and extension into the script which are then used in the shell commands to do the file transcode. So let’s say I have a file called “Socks.mpg”. I want to plug in the name and extension to the script, then issue the shell command which transcodes the file, names it the same thing as the name variable, but adds a different extension.

So what’s my problem? I have the script configured on a folder, but nothing happens when I drag a file in. How can I see what the problem is? Also, when I originally tested this shell command (which works perfectly in /bin/sh and /bin/bash, I get an I/O error in the applescript log telling me that means the file is corrupted. but the same file works fine directly in terminal!). Can anyone shed some light on this? Here’s my script:


on adding folder items to this_folder after receiving added_items
	repeat with i in added_items
		set {Nm, Ex} to {name, name extension} of (info for i)
		
		do shell script "/Users/vtaccess/ffmpeg/ffmpeg -i  " & Nm & Ex & "-vcodec mpeg4 -sameq -acodec aac -ab 448 -ar 480000 -f mp4 " & Nm & ".mp4"
		
	end repeat
end adding folder items to

I am very new at applescript, so I really appreciate any help in advance. Thanks,
j

do shell script always starts in the root folder (‘/’), so you’re script isn’t finding the file. Try something like this:

on adding folder items to this_folder after receiving added_items
	repeat with i in added_items
		set {name:Nm} to (info for i)
		
		do shell script "/Users/vtaccess/ffmpeg/ffmpeg -i  " & (quoted form of POSIX path of i) & "-vcodec mpeg4 -sameq -acodec aac -ab 448 -ar 480000 -f mp4 " & quoted form of POSIX path of (Nm & ".mp4")
		
	end repeat
end adding folder items to

Ah, yes, that helps things out considerably. Thanks very much!