Hi,
I’m trying to make this droplet that simply gets info on the file(s) dropped on it. I keep getting the error messages that the variables are not defined. They are straight out of the AS_QT dictionary. So far i can only get the file name and playtime.
on run
open {choose file}
end run
on open the_files
repeat with this_file in the_files
set the_info to info for this_file
if name of the_info ends with ".wav" or ".snd" or ".aif" or ".aiff" or ".mp3" or ".mp4" or ".aac" or file type of the_info = "MooV" or file type of the_info = "sd2f" or file type of the_info = "AIFF" or file creator of the_info = "sd2a" then my process_this_file(this_file)
end repeat
end open
on process_this_file(this_file)
tell application "QuickTime Player"
open this_file
play movie 1
--GET THIS INFO
set the_file_name to name of movie 1
set playtime to duration / time scale
--set howManyChannels to audio channel count of movie 1
--set bit_rate to audio sample rate of movie 1
--set data_type to data format of movie 1
--set data_kind to kind of movie 1
--set data_rate to data rate of movie 1
set createdOn to creation date of movie 1 as string
set modifiedOn to modification date of movie 1 as string
--DIPLAY THIS INFO
set display_text to ""
set display_text to display_text & "File Name: " & the_file_name & return & return
set display_text to display_text & "Time: " & playtime & return
set display_text to display_text & "Number of Channels: " & audio channel count & return
set display_text to display_text & "Bit Rate: " & return
set display_text to display_text & "Sample Rate " & audio sample rate & " Khz" & return
set display_text to display_text & "File Type: " & kind & return
set display_text to display_text & "Created: " & createdOn & return
set display_text to display_text & "Modified: " & modifiedOn & return
display dialog the display_text buttons {"OK"} default button 1
close movie 1
end tell
end process_this_file
As well does anyone know how to get the audio bit depth?
if name of the_info ends with “.wav” or “.snd” or “.aif” or “.aiff” or “.mp3” or “.mp4” or “.aac” or file type of the_info = “MooV” or file type of the_info = “sd2f” or file type of the_info = “AIFF” or file creator of the_info = “sd2a” then my process_this_file(this_file)
on open the_files
repeat with this_file in the_files
set the_info to info for this_file
set the_extension to (name extension of the_info)
set the_type to (file type of the_info)
set the_creator to (file creator of the_info)
if the_extension is in extension_list or ¬
the_type is in file_type_list or ¬
the_creator is in file_creator_list then
process_this_file(this_file)
end if
(*
if name of the_info ends with “.wav” or “.snd” or “.aif” or “.aiff” or “.mp3” or “.mp4” or “.aac” or file type of the_info = “MooV” or file type of the_info = “sd2f” or file type of the_info = “AIFF” or file creator of the_info = “sd2a” then my process_this_file(this_file)
*)
end repeat
end open
on process_this_file(this_file)
tell application “QuickTime Player”
launch – launches QT without the blank movie
open this_file
play movie 1
--GET THIS INFO
set the_file_name to name of movie 1
set playtime to duration / time scale
--set howManyChannels to audio channel count of movie 1
--set bit_rate to audio sample rate of movie 1
--set data_type to data format of movie 1
--set data_kind to kind of movie 1
--set data_rate to data rate of movie 1
set createdOn to creation date of movie 1 as string
set modifiedOn to modification date of movie 1 as string
--DIPLAY THIS INFO
set display_text to ""
set display_text to display_text & "File Name: " & the_file_name & return & return
set display_text to display_text & "Time: " & playtime & return
set display_text to display_text & "Number of Channels: " & audio channel count & return
set display_text to display_text & "Bit Rate: " & return
set display_text to display_text & "Sample Rate " & audio sample rate & " Khz" & return
set display_text to display_text & "File Type: " & kind & return
set display_text to display_text & "Created: " & createdOn & return
set display_text to display_text & "Modified: " & modifiedOn & return
display dialog the display_text buttons {"OK"} default button 1
close movie 1
end tell
Thanks for the beginning part, but the rest (although it may look good) still does not return any values for the properties (except for name and playtime).
Here is the latest incarnation . . . I’m still trying to put A Rounder Round into this script in 2 places. First to round off the playtime to 2 decimals and then to round off the sample rate to 3 decimals.
property extension_list : {"wav", "snd", "aif", "aiff", "mp3", "mp4", "aac", "m4a"}
property file_type_list : {"MooV", "AIFF", "sd2f"}
property file_creator_list : {"sd2a"}
--
on run
open {choose file}
end run
--
on open the_files
repeat with this_file in the_files
set the_info to info for this_file
set the_extension to (name extension of the_info)
set the_type to (file type of the_info)
set the_creator to (file creator of the_info)
if the_extension is in extension_list or ¬
the_type is in file_type_list or ¬
the_creator is in file_creator_list then
process_this_file(this_file)
end if
end repeat
end open
on process_this_file(this_file)
tell application "QuickTime Player"
launch
open this_file
set audiotrack to track 1 of movie 1
set file_info to info for this_file
play movie 1
--GET THE INFO
set the_file_name to name of movie 1
set playtime to duration / time scale
set howManyChannels to audio channel count of audiotrack
set sample_rate to audio sample rate of audiotrack
set bit_depth to audio sample size of audiotrack
set data_type to data format of audiotrack
set file_type to file type of file_info
set file_creator to file creator of file_info
set createdOn to creation date of file_info
set modifiedOn to modification date of file_info
--DIPLAY THE INFO
set display_text to ""
set display_text to display_text & "File Name: " & the_file_name & return & return
set display_text to display_text & "Time: " & playtime & return
set display_text to display_text & "Number of Channels: " & howManyChannels & return
set display_text to display_text & "Bit Depth " & bit_depth & " bit" & return
set display_text to display_text & "Sample Rate: " & sample_rate & return & return
set display_text to display_text & "File Type: " & file_type & return
set display_text to display_text & "File Creator: " & file_creator & return
set display_text to display_text & "Data Type: " & data_type & return & return
set display_text to display_text & "Created: " & createdOn & return
set display_text to display_text & "Modified: " & modifiedOn & return
display dialog the display_text buttons {"OK"} default button 1
close movie 1
end tell
end process_this_file
Is this close to what you want? I’ve taken the liberty of making some minor optimizations.
property extension_list : {"wav", "snd", "aif", "aiff", "mp3", "mp4", "aac", "m4a"}
property file_type_list : {"MooV", "AIFF", "sd2f"}
property file_creator_list : {"sd2a"}
global the_info
global the_type
global the_creator
--
on run
open {choose file}
end run
--
on open the_files
repeat with this_file in the_files
set the_info to info for this_file
set the_extension to (name extension of the_info)
set the_type to (file type of the_info)
set the_creator to (file creator of the_info)
if the_extension is in extension_list or ¬
the_type is in file_type_list or ¬
the_creator is in file_creator_list then
process_this_file(this_file)
end if
end repeat
end open
on process_this_file(this_file)
tell application "QuickTime Player"
launch
set doc_ref to open this_file
set audiotrack to track 1 of doc_ref
play doc_ref
--DIPLAY THE INFO
set display_text to "File Name: " & name of doc_ref & return & return & ¬
"Time: " & my (trnc from (duration / time scale) onto 2 with rounding) & return & ¬
"Number of Channels: " & audio channel count of audiotrack & return & ¬
"Bit Depth: " & audio sample size of audiotrack & " bit" & return & ¬
"Sample Rate: " & my (trnc from audio sample rate of audiotrack onto 3 with rounding) & return & return & ¬
"File Type: " & the_type & return & ¬
"File Creator: " & the_creator & return & ¬
"Data Type: " & data format of audiotrack & return & return & ¬
"Created: " & creation date of the_info & return & ¬
"Modified: " & modification date of the_info & return
display dialog display_text buttons {"OK"} default button 1
close doc_ref
end tell
end process_this_file
on trnc from N onto d given rounding:rounding
tell 10 ^ d
tell N * ((10 ^ 0.5) ^ 2) * it
if rounding then
it div 5 - it div 10 -- round off
else
it div 10 -- truncate
end if
end tell
result / it -- ie. result / (10 ^ d)
end tell
end trnc