Batch convert animated GIFs to videos using AppleScript/Automator/QuickTime 7 on OS X

When I was doing a VJ thing, the software I used couldn’t handle the animated GIF files I wanted to play. I had a hard time finding a free tool to batch convert animated GIF to movie and not the other way round.

Since I just made that video AppleScript/QuickTime batch converter I thought I could do the same thing with GIFs too. It turned out the standard QuickTime X can’t open them. But QuickTime 7 can! And you can still install it from your OS X Install Disk – at least with Snow Leopard.

So just install QuickTime Player 7 and put this Automator .workflow file into your ~/Library/Services folder. Now select one or more animated GIF files in Finder, right-click them, and choose Services → Convert animated .gif to .mov using QuickTime 7. It will use the most recent QuickTime 7 export settings. You should convert/export one file by hand to adjust the settings.

You’ll see QuickTime Player 7 starting and magically converting one file after another. I found it’s better to leave it alone while it’s doing that.

 

How to do this from scratch?

See my AppleScript/QuickTime batch converter post on how to create a Service for Finder Contextual Menu (the thing that pops up when you do a right-click). But in step 2 use image files instead of movie files and in step 4 use this code:

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

	display dialog "Most recent QuickTime 7 export settings will be used.
Existing files will be overwritten/moved to trash!
Beware of evil QT7 Gamma shift!"

	tell application "QuickTime Player 7"
		activate
		close every window
	end tell

	repeat with currentItem in droppedItems
		tell application "Finder" to set fileName to name of currentItem as Unicode text

		tell application "QuickTime Player 7"
			open currentItem
			tell front document to set frameCount to count of frames of first track
		end tell

		set outputFileName to (outputFolder & fileName & ".mov")

		tell application "Finder"
			if exists file outputFileName then
				delete file outputFileName
			end if
		end tell

		tell application "QuickTime Player 7"
			if frameCount is greater than 1 then
				with timeout of 86400 seconds -- 24 hours
					export front document to outputFileName as QuickTime movie using most recent settings
				end timeout
			end if
			close front document
		end tell
	end repeat

	quit application "QuickTime Player 7"
end open

12 Comments

Leave a comment
  1. Mathias

    Hallo Peter

    Ich bin auf deinen Automator-Workflow gestossen, das wäre genau was ich brauche.
    Leider finde ich bei mir keinen Verzeichnis “Services” in meinem Library Ordner.

    Wenn ich das File doppelklicke und in Automator öffnen will, bekomme ich die Meldung, dass die Datei beschädigt, oder unvollständig sei.

    Hast du eine Ahnung, wie ich den Workflow zum Laufen bringe.
    Auf meinem Mac ist OSX 10.6.8 installiert…

    Besten Dank für deine Hilfe!

    • Peter Bartz

      Hey Mathias,

      if there is no “Services” folder in your home library (“~/Library”), I think you should just create it and you will be fine.
      OS X Mountain Lion asks you if you want to install or open a .workflow file when you doubleclick it, but on Snow Leopard I think that’s not the case and you have to do it manually.

      And thanks a lot for pointing that out… there indeed was something wrong with the download. I just fixed it. :)

      Cheers,
      Peter

  2. Mathias

    Hi Peter,

    Like you suggested, I just created the missing “Services” folder in my Library and added your new workflow file.
    Now everything works like a charm…

    Great work, thanks a lot for your time and support!
    Mathias

  3. Hi Peter,

    Per our offline e-mails, I’ve published a FAQ using a variation of your AppleScript code to batch-convert old mobile phone movies in 3GP and 3G2 format to MP4 format for use on an iPhone. Your excellent post was just the thing I needed to automate this process in QuickTime 7 Pro without having to write an AppleScript from scratch.

    My FAQ can be found here: http://www.thexlab.com/faqs/iphone_3gp_3g2_mp4.html

    Thanks for sharing your great work!

    ;-) Doc

  4. Ryan

    You are a MIRACLE. Thank you!!!

  5. chris

    I`m using lion 10.7.5
    I have quick time 7 installed
    I created a Services folder in Library, pasted the work flow file, installed it.
    When I control click on the gif file that I want to convert, I don`t see a services option. I do have the option to open it in quick time but there is parameter to convert the file to movie.
    Any suggestions?
    Thx
    Chris

    • Peter Bartz

      Hi Chris,
      no idea, what’s wrong there… I’m running Mountain Lion and it still works the same as on Snow Leopard.
      Make sure, you put the workflow into your user library (~/Library/Services) and not the system library.
      Cheers,
      Peter

  6. Claire

    Wow… thank you so much!! I have just spent ALL DAY trying to do this, searching for software that would work, and I beginning to think I was the only one wanting to convert FROM and not TO a gif!! And on a Mac as well!

    I could hug you.

    Followed the instructions and all worked fine., The only thing I couldn’t do is change the export settings on Quicktime 7 as the export feature is greyed out, saying it is only available in the Pro version? Luckily the export settings seem fine.

    Claire

  7. Thanks so much for this! It’s wonderful!!!!

  8. Dandaka

    Your script is not working in OSX Mavericks / Automator. But I’ve managed to get it working another way (AppleScript / Application). If someone is interested, here is how:
    https://discussions.apple.com/message/24362308?ac_cid=op123456#24362308

  9. Thank you, this saved me sooo much time!

Leave a Comment