Batch convert AVI and other videos files via the Contextual Menu in Finder using AppleScript/Automator/QuickTime on OS X

I really like my Canon IXUS camera, but when it comes to making videos it always bugged me having these huge uncompressed .avi files filling up my disk. QuickTime is free and has a .H264 export option with some presets built in, but no batch mode. You have to convert videos by hand – one at a time.

If I had lots of files, wouldn’t it be much easier to just select some video files in Finder, right-click and convert them?
And it is all possible using AppleScript, Automator and the Contextual Menu – a.k.a. Services.

Just put this Automator .workflow file into your ~/Library/Services folder. Now select one or more movies in Finder, right-click them, and choose Services → Convert video(s) using QuickTime. You can choose between the presets QuickTime offers… try them and see what they do. I usually use 480p and 720p.

You’ll see QuickTime Player starting and magically converting one video file after another. I found it’s better to leave it alone while it’s doing that. Your files will be output as


How to do this from scratch?

1. Open up Automator, which comes with OS X. Create a new Service with FileNew… and choose the Service template.


2. At the top of the window, set up the Service to receive movie files from Finder.


3. From the left side, drag a Run AppleScript action into your workflow in the middle.


4. Insert this AppleScript into your action:

on run {inputFiles}
	if inputFiles is equal to {} then
		set inputFiles to (choose file with prompt "Select the file(s) to convert:" with multiple selections allowed without invisibles)
	end if
	open inputFiles
end run

on open droppedItems
	tell application "Finder" to set inputFolder to (container of first item of droppedItems) as Unicode text
	set outputFolder to (choose folder with prompt "Select output folder:" default location (inputFolder as alias)) as Unicode text

	set exportPreset to (choose from list {"Movie", "iPhone", "iPod", "HD 480p", "HD 720p"} with prompt "Choose QuickTime Export Preset:") as Unicode text
	if exportPreset is equal to "false" then
	end if

	repeat with currentItem in droppedItems
		repeat until getProcessPercentCPU("CoreMediaAuthoringSessionHelper") is equal to ""
			delay 30
		end repeat

		tell application "Finder" to set fileName to name of currentItem as Unicode text
		convertFile(currentItem, outputFolder & fileName & ".mov", exportPreset)
		delay 30
	end repeat
end open

on convertFile(inputFile, outputFile, exportPreset)
	tell application "QuickTime Player"
		set thisMovie to open inputFile
		export thisMovie in (outputFile) using settings preset exportPreset
		close thisMovie
	end tell
end convertFile

on getProcessPercentCPU(processName)
	do shell script "/bin/ps -xco %cpu,command | /usr/bin/awk '/" & processName & "$/ {print $1}'"
end getProcessPercentCPU

Then save – I used Convert video(s) using QuickTime as file name. Automator then automatically saves your workflow to your user service directory at ~/Library/Services. If you don’t want it any more, just delete it.


Leave a comment
  1. Does this require Quicktime pro or just the player?

  2. Stevey

    Thank-you, Peter.

    This is completely wonderful. I have been laboriously converting my videos from 1080p to 480p one-at-a-time, open-export-close-style. No more.

    People like you make the internet a lovely thing. Noch mal Vielen Dank.


  3. Ben

    Hi Peter,

    This looks very promising, but it doesn’t seem to work in Mavericks. I tried both the workflow and creating the automator job from scratch. Neither seems to do anything. I quickly attempted to trace the script code to see where it was failing but came up short. Automator reports no errors but no output files are ever created and when watching Activity Monitor I don’t see any kind of spike in Quictime CPU usage.


  4. Ben

    PS, I looked into the automator action “Encode Media” but it changes the file extension (and possibly the encode format?) and it also automatically drops the frame rate to 30fps which I don’t want. Not sure if your script does this? I am hoping it provides the same results as the File > Export > … options in Quicktime itself which gives great results!

Leave a Comment