Need help with applescript to convert audio files using ffmpeg

Posted:
in macOS edited January 2014
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:nickesktop:new:"

set outPath to "Macintosh HD:Users:nickesktop: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:nickesktop: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

Comments

Sign In or Register to comment.