Hello - I’m new to the forums and would like to find an Applescript programmer to create a “droplet” for us.
The job:
We need a droplet that we can drag a folder of Quicktime movies on to, have the droplet open each movie, then do an Export to a specific format.
We would like the export to go a specific directory path in User > Documents.
Finally, the script deletes the original folder of clips.
If you are interested and would like further details, please email with your contact information and the rate and estimated time that you’ll need to complete the job.
property exportFolder : (path to documents folder as Unicode text) & "Your Folder:"
on run
choose folder with prompt "Change video files from these folders:" with multiple selections allowed
open (result)
end run
on open droppedItems
tell application "QuickTime Player"
activate
close every window
end tell
repeat with thisItem in droppedItems
if (folder of (info for thisItem without size)) is true then
list folder thisItem without invisibles
repeat with thisFile in (result)
tell application "QuickTime Player"
open ((thisItem as Unicode text) & thisFile)
if (can export (front movie) as DV stream) is true then
try
export front movie to (exportFolder & thisFile & ".dv") as DV stream
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
else
display dialog "QuickTime Player can't export "" & (thisFile as Unicode text) & "" as DV stream." buttons "OK" default button 1 with icon caution
end if
close front movie
end tell
end repeat
try
tell application "Finder" to delete thisItem
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
end if
end repeat
quit application "QuickTime Player"
end open
I too found the above-noted script quite handy. But I’d like to add one thing. I gave it a try and QT gave me an error “(8)”. What I’d like to add is 2 additional prompts: I’d like to be asked to set an “Export to:” destination. And I’d like to be asked to select the particular quicktime export settings file too.
Hope you can help me…I’ll attach my current script:
on run
choose file with prompt "Select the file(s) to export:" with multiple selections allowed without invisibles
open result
end run
on open droppedItems
tell application "QuickTime Player"
activate
close every window
end tell
set saveLocation to (choose folder with prompt "Select destination for exported files:")
set exportSetting to (choose file with prompt "Select the QT export settings file:")
repeat with thisItem in droppedItems
set thisName to name of (info for thisItem without size)
tell application "QuickTime Player"
open thisItem
if (can export front movie as QuickTime movie) then
try
export front movie to (saveLocation & thisName) as QuickTime movie ¬
using settings file alias (exportSetting)
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
else
display dialog "QuickTime Player can't export "" & (thisFile as Unicode text) & "" as H.264." buttons "OK" default button 1 with icon caution
end if
close front movie
end tell
end repeat
quit application "QuickTime Player"
end open
I’m checking it out. Do you always want to export to a QuickTime movie?
Edit: Try something like this:
-- Try to save some default folders, so you don't jump back and forth for videos and settings file.
property chooseFileFolder : ""
property settingsFolder : ""
on run
checkAlias(chooseFileFolder)
choose file with prompt "Select the file(s) to export:" default location result with multiple selections allowed without invisibles
set chosenFiles to result
set chooseFileFolder to parentFolder(first item of chosenFiles)
open chosenFiles
end run
on open theseItems
choose folder with prompt "Choose destination for exported file(s):"
set exportFolder to result as Unicode text
checkAlias(settingsFolder)
choose file with prompt "Choose the QuickTime export settings file:" default location result
set exportSettingsFile to result
set settingsFolder to parentFolder(exportSettingsFile)
try
tell application "QuickTime Player"
activate
close every window
end tell
end try
repeat with thisItem in theseItems
-- Use the original name for the exported file
set {name:thisName, folder:isFolder} to (info for thisItem without size)
-- Skip any folders that were dropped
if not (isFolder) then
-- Remove extension from original name, if any
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"."}
try
set thisName to text 1 thru text item -2 of thisName
end try
set AppleScript's text item delimiters to ASTID
tell application "QuickTime Player"
try
open thisItem
if (can export front movie as QuickTime movie) then
-- If the AppleScript takes too long (more than a minute) on a certain command, it will throw a timeout error.
-- Use a `timeout` block when something might take longer to finish.
with timeout of 86400 seconds -- 24 hours
export front movie to (exportFolder & thisName) as QuickTime movie using settings exportSettingsFile
end timeout
else
display dialog "QuickTime Player can't export "" & thisName & "" as a QuickTime movie." buttons {"Skip File"} default button 1 with icon caution
end if
on error errMsg number errNum
if errNum is -2019 then set errMsg to "The export was canceled in QuickTime Player."
display dialog "Error " & errNum & return & return & errMsg buttons {"Cancel Script", "Skip File"} default button 2
if (button returned of result) is "Cancel Script" then error number -128
end try
try
close front movie saving no
end try
end tell
end if
end repeat
quit application "QuickTime Player"
tell me to display dialog "Export script finished!" buttons {"View Export Folder", "OK"} default button 2 with icon note
if (button returned of result) is "View Export Folder" then tell application "Finder" to open exportFolder
end open
on checkAlias(someItem)
try
return someItem as alias
on error
return path to home folder
end try
end checkAlias
on parentFolder(someItem)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
try
set someFolder to (text 1 thru text item -2 of (someItem as Unicode text)) & ":"
on error
set someFolder to ""
end try
set AppleScript's text item delimiters to ASTID
return someFolder
end parentFolder
Bruce,
Thanks for the response. And to answer your intitial question, yes, in this circumstance I am always going to want to export to .mov.
I ran the script but it hang up and said, “The variable result is not defined.” then pointed me to this section of script:
repeat with thisItem in theseItems
-- Use the original name for the exported file
set {name:thisName, folder:result} to (info for thisItem without size)
what do you think?
thanks for the help thus far, KB
Bruce,
Thanks so much. I ran the script posted above and it seemed to worked fine for me. I ran it on a singular file - not a multiple selection. But it worked great. Thanks for your time & energy on this.
All the best, Kevin
I grabbed the script you had posted (which works great), but I’m new to Applescript, so please bear with me:
I entered a path for the settings, but it still prompted me for the path. Here is what I had entered: (H264 is the settings file I had exported from QT)
property settingsFolder : “/Users/john/Documents/H264”
How do I make this script become a droplet, so all I need to do is drop a quicktime file onto it, have it read the path to the settings, and save the file to the same location with the same name but with a _H264 added to the name?
Appreciate the help.
Thanks;
John
Browser: Firefox 2.0.0.12
Operating System: Mac OS X (10.4)
Thank you! That was very helpful. Managed to figure out the rest of my questions, except for this:
In the script, the name of the exported file is the same as the original name. How do I add an extension, like _H264 to it? Looking at the code, this is how the name is set:
set {name:thisName, folder:isFolder} to (info for thisItem without size)
I modified the script. It’s now adding it after the .mov extension, so the file is now called .mov_H264, instead of _H264.mov
Also, the script complains if the exported filename already exists in that location. Is there a way to override that, and just have it always write over an existing file?
I’m pretty new to this. I’ve tried using this script with a couple of modifications only to be stopped dead in my tracks. I’ve trying to modify this to process thousands of sd2 files in descriptive folders to Wav (Quicktime’s default settings are fine) to the same directory that the original file is from. When I first got it to run using a modified version at the top of this page, I got it to work fine until it encountered a directory with any subfolders.
I then decided to modify it some more and pair it with automator with these actions:
–>Get Selected Finder Items
–>Get Folder Contents (with Repeat for each subfolder found checked
–>Open Finder Items (Opens with the applescript droplet that I’m including below)
on run
choose file with prompt "Change audio files from these folders:" with multiple selections allowed
open (result)
end run
on open droppedItems
tell application "QuickTime Player"
activate
close every window
end tell
repeat with thisFile in droppedItems
tell application "Finder"
get folder of (thisFile) as Unicode text
set workingDir to POSIX path of result
end tell
tell application "QuickTime Player"
open (thisFile)
if (can export (front document) as wave) is true then
try
export front document to (workingDir & thisFile & ".wav") as wave
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "OK" default button 1 with icon caution
end try
else
display dialog "QuickTime Player can't export "" & (thisFile as Unicode text) & "" as Wave." buttons "OK" default button 1 with icon caution
end if
close front document
end tell
end repeat
quit application "QuickTime Player"
end open
The problem that I’m having now is that it justs opens up the first file and just hangs there. I have to do a force quit on Quicktime.
I could be making this way harder than it needs to be. Any help will be very appreciated. This is my first real time with applescript.
Best,
Jeremy
Model: iMac Intel 2.4 Ghz
AppleScript: 2.0.1
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)
While I can’t help with the last question - I do have one of my own.
I’m trying to convert to iPhone format and have setup a settings file as well as used the format explicitly in the script as follows:
export front document to (exportFolder & thisName & “.mv4”) using most recent settings
and
export front document to (exportFolder & thisName & “.mv4”) as iPhone
and
export front document to (exportFolder & thisName & “.mv4”) as MPEG4
However, the exported file always results in a Quicktime file in a DV format. I convert a file with iPhone settings manually before trying the first statement. The second and third statements are valid formats in the Dictionary for the Quicktime player.
I just tried ‘as iTunes’ for the export setting and the videos plays on the iPod Touch. Even seems to work on systems that don’t have Quicktime Pro enabled.