Created
September 4, 2010 17:18
-
-
Save alexeypegov/565328 to your computer and use it in GitHub Desktop.
Convert AVI files to M4V (iPhone) one by one using QuickTime Player X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- simple AppleScript to convert chosen AVI files to iPhone video format one by one using QuickTime Player X | |
-- | |
property outputFolder : (path to movies folder as Unicode text) | |
on check_exists(fileToCheck) | |
repeat | |
tell application "Finder" | |
if exists file fileToCheck then | |
exit repeat | |
end if | |
end tell | |
delay 5 | |
end repeat | |
end check_exists | |
on export_files(theFiles) | |
repeat with currentFile in theFiles | |
set AppleScript's text item delimiters to ":" | |
set filePath to (currentFile as string) | |
set _fileName to (text item -1 of filePath) | |
set AppleScript's text item delimiters to "." | |
set fileName to (text items 1 through -2 of _fileName) as string | |
set fileExt to (text item -1 of _fileName) as string | |
if (fileExt is equal to "AVI") then | |
set shouldCheck to yes | |
tell application "QuickTime Player" | |
open filePath | |
set exportFile to (outputFolder & fileName & " (iPhone).m4v") | |
try | |
export front document in (exportFile) using settings preset "iPhone" | |
on error errorMsg number errorNum | |
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution | |
set shouldCheck to no | |
end try | |
close front document | |
end tell | |
if shouldCheck is yes then | |
check_exists(exportFile as Unicode text) | |
tell application "iTunes" | |
add (exportFile as alias) | |
end tell | |
end if | |
end if | |
end repeat | |
tell application "QuickTime Player" to quit | |
end export_files | |
export_files(choose file multiple selections allowed yes) | |
on open theFiles | |
export_files(theFiles) | |
end open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment