Need help with applescript to convert audio files using ffmpeg

Joined
Feb 24, 2007
Messages
100
Reaction score
0
Points
16
Hi

I have installed ffmpeg using MacPorts and am trying to work out a script that will convert audio files in a specified folder to mp3 files, outputting the converted files as mp3 files in another folder.

So far the script looks like this:

Code:
set convertPath to "Macintosh HD:opt:local:bin:ffmpeg"
set convertCommand to quoted form of POSIX path of convertPath & " -i {infile} -f mp3 -ar 44100 -ab 128 -acodec mp3 - "

tell application "Finder"
	set inPath to "Macintosh HD:Users:nick:Desktop:new:"
	set outPath to "Macintosh HD:Users:nick:Desktop:new2:"
	set myFiles to (files of entire contents of inPath whose name ends with ".m4a") as alias list
	
	repeat with i from 1 to count of myFiles
		do shell script convertCommand
	end repeat
	
end tell

With this script I am getting the error : "Can’t make every file of «class ects» of "Macintosh HD:Users:nick:Desktop:new:" whose name ends with ".m4a" into type alias list."

Another issue is that I am not sure how to define the do shell script command so that it outputs an MP3 file in the output directory.

Could someone help me get this working?

Thanks

Nick
 
OP
N
Joined
Feb 24, 2007
Messages
100
Reaction score
0
Points
16
thanks, but i'd rather stick to AppleScript if possible as the conversion will be part of a larger script performing a few functions, and I'd also like to use ffmpeg for precise control of bitrate, etc. within the script
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top