Hi,
I’ve done a lot of learning on this so far but it’s time to ask for help!
I’m working on a script that will First check the filenames of movie files in a specified folder (‘Input’ on the desktop), rename them if necessary based on their creation date, then export them as QuickTime movies. The QT export works fine but the checking and renaming doesn’t seem to be.
Acknowledgement here for the export script that this is based on
http://ldopa.net/2008/05/23/batch-export-for-quicktime-pro/
Script and result below:
Thanks for any help!
with timeout of 86400 seconds
display dialog "Before beginning batch processing, make sure QuickTime Player is set to the desired export settings, and all videos to be processed are in a folder named ˜Input' on the desktop." with icon note
tell application "Finder"
set the startup_disk to the name of the startup disk
end tell
set user to do shell script "whoami"
set input_folder_name to "Input"
set input_folder to startup_disk & ":Users:" & user & ":Desktop:" & input_folder_name & ":"
set user_desktop to startup_disk & ":Users:" & user & ":Desktop:"
set output_folder to startup_disk & ":Users:" & user & ":Desktop:Output:"
set file_extension to "_export.mov"
try
tell application "Finder"
make new folder at user_desktop with properties {name:"Output"}
end tell
end try
try
set the_folder_list to list folder input_folder without invisibles
repeat with x from 1 to count of the_folder_list
set the_file to item x of the_folder_list
set the_file_name to the name of the_file
tell application "Finder"
if the_file_name begins with "IMG" then
set the item_info to the info for the_file
set the_date to the creation date of the item_info
set the_day to day of the_date
set DD to the_day
if the_day < 10 then set DD to "0" & the_day
set the_month to (month of the_date) * 1
set MM to the_month
if the_month < 10 then set MM to "0" & the_month
set yyyy to year of the_date
set the_time to (time of the_date)
set the_hour to the_time div hours
set HH to the_hour
if the_hour < 10 then set HH to "0" & the_hour
set the_minutes to the_time mod hours div minutes
set MN to the_minutes
if the_minutes < 10 then set MN to "0" & the_minutes
set the_seconds to the_time mod hours mod minutes
set SS to the_seconds
if the_seconds < 10 then set SS to "0" & the_seconds
set new_name to "CANON" & yyyy & "-" & MM & "-" & DD & " " & HH & ";" & MN & ";" & SS & ".mov"
set the name of the_file to new_name
end if
end tell
end repeat
end try
try
set the_folder_list to list folder input_folder without invisibles
repeat with x from 1 to count of the_folder_list
set the_file to input_folder & item x of the_folder_list
set output_file to output_folder & item x of the_folder_list & file_extension
tell application "QuickTime Player 7"
activate
open the_file
export front document to output_file as QuickTime movie using most recent settings with replacing
close front document
end tell
end repeat
on error
display dialog "This script requires a folder named ˜" & input_folder_name & "˜ located on the desktop." with icon stop
end try
say "Finished"
end timeout
and result:
tell application "AppleScript Editor"
display dialog "Before beginning batch processing, make sure QuickTime Player is set to the desired export settings, and all videos to be processed are in a folder named ˜Input' on the desktop." with icon note
--> {button returned:"OK"}
end tell
tell application "Finder"
get name of startup disk
--> "Macintosh HD"
end tell
tell current application
do shell script "whoami"
--> "cameronh"
end tell
tell application "Finder"
make new folder at "Macintosh HD:Users:cameronh:Desktop:" with properties {name:"Output"}
--> error "The operation can't be completed because there is already an item with that name." number -48
end tell
tell current application
list folder "Macintosh HD:Users:cameronh:Desktop:Input:" without invisibles
--> {"clip-2011-12-01 11;15;28.mov", "IMG_0217.MOV"}
list folder "Macintosh HD:Users:cameronh:Desktop:Input:" without invisibles
--> {"clip-2011-12-01 11;15;28.mov", "IMG_0217.MOV"}
end tell
tell application "QuickTime Player 7"
activate
open "Macintosh HD:Users:cameronh:Desktop:Input:clip-2011-12-01 11;15;28.mov"
--> document "clip-2011-12-01 11;15;28.mov"
export document 1 to "Macintosh HD:Users:cameronh:Desktop:Output:clip-2011-12-01 11;15;28.mov_export.mov" as QuickTime movie using most recent settings with replacing
close document 1
activate
open "Macintosh HD:Users:cameronh:Desktop:Input:IMG_0217.MOV"
--> document "IMG_0217.MOV"
export document 1 to "Macintosh HD:Users:cameronh:Desktop:Output:IMG_0217.MOV_export.mov" as QuickTime movie using most recent settings with replacing
close document 1
end tell
tell current application
say "Finished"
end tell
The file staring with IMG doesn’t get renamed, but the files export correctly apart from that.
Thanks for any help.