converting AIFF files to AAC

As part of my work as a science writer, I frequently record interviews that I subsequently transcribe. All the recording hardware and software I use produces AIFF files, but these are huge and so I always convert them to AAC and trash the original AIFFs.

I do this manually, copying the AIFF files into iTunes, selecting the Convert to AAC menu item, then copying the resulting AAC files back to the folder where the original AIFF files resided (I don’t want to keep everything in iTunes), and finally deleting the AIFF and AAC files from my iTunes library.

What I’d like to be able to do is drag the original AIFF file onto a script applet, have it mobilize iTunes to do the conversion, and have the resulting AAC file appear in the same folder as the original AIFF file - without creating copies in my iTunes library.

Is this doable?


Here is a quick hack that worked for me. It should be easy to refine it and make a droplet to suit your needs.

set original_file to (path to desktop as text) & “whatever.aiff”

on convert(original_file)
set save_tids to AppleScript’s text item delimiters

tell application "iTunes"
	set current encoder to encoder id 35 -- AAC, at least on my machine
	set converted to item 1 of (convert {original_file as alias})
	set converted_file to (location of converted) as text
end tell

set AppleScript's text item delimiters to ":"
set original_file_folder to (text items 1 thru -2 of original_file) as text
set AppleScript's text item delimiters to ""
tell application "Finder" to move file converted_file to folder original_file_folder with replacing

tell application "iTunes"
	tell library
		delete converted
	end tell
end tell

set AppleScript's text item delimiters to save_tids
tell application "Finder" to delete file original_file

end convert

Here is my response. The main difference is that my script uses whatever encoder that iTunes is currently set to (in the Preferences pane) instead of setting the encoder manually. You should be able to save this as an application onto your desktop and it will function as a droplet for a file, or a folder of files to convert. The coverted files will then be moved to a folder entitled ‘Converted.’

on open some_items
	repeat with this_item in some_items
		tell application "Finder"
			if not (exists folder "Converted" of container of this_item) then
				make new folder at container of this_item with properties {name:"Converted"}
			end if
			set the destination_folder to folder "Converted" of container of this_item as alias
		end tell
	end repeat
	tell application "iTunes"
		set new_tracks to (convert some_items)
	end tell
	repeat with this_track in new_tracks
		tell application "iTunes" to set track_loc to (location of this_track)
		tell application "Finder" to move file track_loc to destination_folder
		tell application "iTunes" to delete this_track
	end repeat
end open

I know it is kind of clunky and un-neat, but it should work. Let me know what you think.


Wow! This is fabulous. Thank you so much. It works like a charm.