I’ve been using scripts with Quicktime for a while now but with Quicktime X and OS 10.6 things don’t work the same.
What I like about Quicktime X is it’s simplicity. There are not many options and the options that there are work well and fast. I tend to post a lot of Quicktime movie files for work and there’s always a need to support a variance of download and upload speeds.
I normally start with an uncompressed Quictime and make the compressed versions from there. This ‘versioning’ tends to grow into quite a lot of work with a many Quicktime movie files as sources.
I started on this script that is meant to take a folder of uncompressed Quicktime movie files and duplicate it in another location whilst also making the various compressed versions.
I’ve hit a snag or two. The largest one Quicktime X’s seemingly lack of support to scripting, the other a file naming issue where removing the extension from a filename is not working.
Any insight/help/recommendations are much appreciated.
V.
Here’s my script:
-- define export presets as listed in Quicktime X :
property moviePreset1 : "iPhone"
property moviePreset2 : "HD 480p"
property moviePreset3 : "HD 720p"
property moviePreset4 : "HD 1080p"
property ext1 : "_iPhone"
property ext2 : "_480p"
property ext3 : "_720p"
property ext4 : "_1080p"
-- define actions on run
on run
-- ask for source folders
choose folder with prompt "Choose SOURCE Folder(s):" with multiple selections allowed without invisibles
open (result)
end run
-- define actions
on open droppedItems
--ask for destination folder
choose folder with prompt "Choose a DESTINATION Folder:"
set exportFolder to result
repeat with thisFolder in droppedItems
get name of (info for thisFolder without size)
try
set importFolder to result
end try
tell application "Finder"
-- check if folder exists
if not (exists folder importFolder of exportFolder) then
try
-- make a new folder with the same name as the source folder in the destination folder
make new folder at exportFolder with properties {name:importFolder}
-- define target folder
set targetFolder to result as Unicode text
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg ¬
buttons "Cancel" default button 1 with icon caution
end try
else
-- we're not overwriting previously made folders nor incrementing
display dialog "There is already a folder named " & importFolder & " in " & exportFolder & return & ¬
return & "Please rename or remove that folder first and try again" buttons {"Cancel"} default button 1
end if
end tell
if (folder of (info for thisFolder without size)) is true then
list folder thisFolder without invisibles
repeat with thisFile in (result)
tell application "QuickTime Player"
-- start the application
launch
-- open the movie file
set thisMovie to open ((thisFolder as Unicode text) & thisFile)
-- take the file extension off the filename (version 1)
# set AppleScript's text item delimiters to {"."}
# get name of (info for thisFile without size)
# try
# set targetName to (text items 1 thru -2 of result) as text
# on error
# set targetName to result
# end try
# set AppleScript's text item delimiters to {""}
-- take the file extension off the filename (version 2)
try
set the fileName to the name of thisFile
set fileExt to the name extension of thisFile
if the fileExt is "" then
set the trimmedName to the fileName
else
set the trimmedName to text 1 thru -((length of fileExt) + 2) of the fileName
end if
set targetName to trimmedName as Unicode text
on error
-- give up on removing the file extension
set targetName to thisFile
end try
-- save in new file
try
save thisMovie in ((targetFolder as Unicode text) & targetName & "_copy") with icon
-- the following does not work in Quicktime X ... Also, it could be cleaner.
save thisMovie as moviePreset1 in ((targetFolder as Unicode text) & targetName & ext1) with icon
save thisMovie as moviePreset2 in ((targetFolder as Unicode text) & targetName & ext2) with icon
save thisMovie as moviePreset3 in ((targetFolder as Unicode text) & targetName & ext3) with icon
save thisMovie as moviePreset4 in ((targetFolder as Unicode text) & targetName & ext4) with icon
end try
-- purge the open movie data
close thisMovie
end tell
end repeat
end if
end repeat
end open