or Connect
AppleInsider › Forums › Software › Mac OS X › need help with afconvert command
New Posts  All Forums:Forum Nav:

need help with afconvert command

post #1 of 7
Thread Starter 
hi

i am trying to use the afconvert command for the first time, to convert AAC audio files added to a specific folder in finder to WAV files. I have done a bit of searching about but can't work out how to write the afconvert command.

ultimately i would like to have a script with the afconvert command which would run as a folder action when AAC files are added to the folder, and ideally I would like the original AAC files to be deleted, but first off i need to get the afconvert command working.

i would be grateful if someone could let me know how to write the command line

thanks

nick
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
post #2 of 7
To find all the output formats, type afconvert -h. The example below does .wav output. You need the -d flag to specify the format. You can choose big endian or little endian, float/int/unsigned int, and your sample rate. So a Big Endian Integer 16-bit 44.1kHZ would be: -d BEI16@44100

afconvert -f 'WAVE' -d I16@44100 input.aac output.wav

I'd recommend doing a move to trash instead of delete in case the program has some sort of error.
post #3 of 7
Thread Starter 
hey marvin

thanks a lot for the command. how would i use this in a folder action? do i have to put it in a script?

sorry for being a bit thick in this regard

nick
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
post #4 of 7

Or you can convert ONline

post #5 of 7
Quote:
Originally Posted by nick_harambee View Post

hey marvin

thanks a lot for the command. how would i use this in a folder action? do i have to put it in a script?

Yeah, you have to put it in an Applescript like this one:

Code:


on adding folder items to this_folder after receiving added_items
try
tell application "Finder"
set the folder_name to the name of this_folder
end tell

set the item_count to the number of items in the added_items
tell application "Finder"
repeat with opath in added_items
set ppath to quoted form of POSIX path of opath
if ppath as text does not end with ".wav'" then
do shell script "afconvert -f 'WAVE' -d I16@44100 " & ppath & "; mv " & ppath & " ~/.Trash"
end if
end repeat
end tell
end try
end adding folder items to



You'd open Applescript Script Editor, paste that into it and save it as something like wavconvert in the folder /Library/Scripts/Folder Actions. Then you'd right-click a folder and enable actions and assign that one to it. When you drop an audio file into it, it should trigger after a few seconds, convert to .wav and move the original to trash.

Folder actions are a bit odd because if you have a script that creates a file inside the folder, it triggers the action again. So for example, without the extension check above, if you drop an mp3 into the folder, it creates a wav file but the folder then thinks you've just added a wav file to it so it runs the script again and it goes into an infinite loop.

I think a more popular method is to use a droplet so you'd grab a bunch of files and drop them onto it. It would then start converting the files and move them to a given folder. This isn't as convenient if you have multiple folders setup or you change the location but you get more control.
post #6 of 7
Thread Starter 
hey marvin

you're a star. this script does exactly what i want it to do, and so far is working without any problems. thanks so much, you have really improved my workflow!!

nick
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
OS X 10.6.2
Mac Pro
2 x 3 GHz Dual-Core Intel Xeon
8 GB RAM
Reply
post #7 of 7

Here's a nice audio converter for core audio formats. http://gngrwzrd.com/microac/

New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Mac OS X
AppleInsider › Forums › Software › Mac OS X › need help with afconvert command