Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shouldn't Automator be easier to use than writing shell scripts?
#1
Programming is not really my thing, but I have managed to get this far... I managed to write up a Shell script (bash) that uses ffmpeg and LAME to batch convert .aif files into both .ogg and .mp3 at the same time, but apparently it is beyond my ability to get Automator to set that up to run as a drag&drop application.

The script goes like this, and works fine in the Terminal:
for x in *.aif;
do name=`echo $x | cut -d'.' -f1`;
echo $name;
ffmpeg -i $x -acodec libvorbis -aq 8 $name.ogg;
lame $x -ab 128k $name.mp3;
done

You just cd to the directory in which you have the .aif files you want to process, then run the script and it spits out .ogg and .mp3 copies for each .aif.

I added that to a "Run Shell Script" node in Automator, and tried all manner of options to get the input (folder from Finder, or just files) to process, but I always get an error saying that the Run Shell Script action encountered an error, with no more details.

Based on my searches I am pretty sure I need to add in a variable to the script that tells it the location of the Folder I have selected in the Finder using "$@":
for x in "$@";
do name=`echo $x | cut -d'.' -f1`;
echo $name;
ffmpeg -i $x -acodec libvorbis -aq 8 $name.ogg;
lame $x -ab 128k $name.mp3;
done

but that didn't help at all. I have tried changing the Pass input setting from "as arguments" to "to stdin", and don't know where to go next... Any ideas?
Reply
#2
some ideas

-try AppleScript. you seem to know enough to try apple script

-what about folder Actions? make a new folder on dekstop, see if you can attach this script to that folder, then drag a bunch of .aif files and it should produce your mp3 and ogg files after which you copy these back to original folder. clean the script folder and now move to another folder you want to process.

Also Apple discussion forums seem to have a lot of helpful folks.
Reply
#3
Not a direct answer to your question but try Max. It's free and can convert into multiple formats of your choosing from preferences. It can be a little wonky until you learn some of the quirks.
Reply
#4
I used to write shell scripts, but I kept getting sand on my desk, and kept accidentally breaking the shells.
Reply
#5
deckeda wrote:
Not a direct answer to your question but try Max. It's free and can convert into multiple formats of your choosing from preferences. It can be a little wonky until you learn some of the quirks.

Excellent! This is a solution I like- I can setup the prefs to covert all input files into both ogg and mp3 at the same time, and it seems to process the files in parallel which should be a real time-saver. Thanks!
Reply
#6
Ugh. I have used all three - AppleScript, shell scripting, and Automator, and what you are trying to do - intermingle inputs and outputs between the two - can be quite challenging.

At the moment I have no direct insight for you other than to say you're on the right track - you need to pass the finder's folder to the shell script as a variable; but it looks like the way you did that lost your selection for *.aif files?

good luck!
g=
Reply
#7
I'd wonder if you couldn't set it up as a folder action for files dropped into the folder.

Add .aif files to folder, convert to OGG/MP3 using shell script step, move files back to desktop for storage/use.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)