The script opens a folder and processes only audio files (wav’s, aif’s, or mp3’s), then opens each in QT and gets their duration in minutes and seconds. The questions that I have are in the comments, which start with “***”. Any help would be appreciated. I’m using Tiger 10.4.4 and the latest version of QT.
property extension_list : {"AIFF", "MPG3", "WAVE"}
tell application "Finder"
activate
set name_text to ""
set mycount to 1
set this_folder to choose folder with prompt "Choose a folder to list:"
set the folder_items to (every item of this_folder)
-- set the folder_path to this_folder as string
repeat with i from 1 to the count of the folder_items
set this_item to (item i of the folder_items)
try
if (the file type of this_item is in the extension_list) then
-- ******** I have to open an alias. If I open the actual reference, it opens in the default application for that file instead of Quicktime - why?
set this_one to this_item as alias
tell application "QuickTime Player"
open this_one
set the time_scale to the time scale of movie 1
set the movie_duration to the duration of movie 1
-- ******* this calculation has to happen all in one step. If I try and break it down into multiple steps, it breaks the script:
set the movie_length to ((((movie_duration / time_scale) div 60) * 10 div 10) as string) & ":" & (((((movie_duration / time_scale / 60) - ((movie_duration / time_scale) div 60)) * 60) * 10 div 10) as string)
close movie 1
end tell
set name_text to name_text & mycount & " " & the name of this_item & " " & movie_length & (ASCII character 13)
set mycount to mycount + 1
end if
on error error_message number error_number
end try
end repeat
display dialog name_text
end tell