Trim Audio Files with QuickTime Player?

Hi. I am new to applescript and I don’t know if this is possible. I have audio files from internet radio that I’d like to clean up the beginnings and endings. I can do this manually by opening the audio file in QuickTime Player and manually moving the selection markers and then choosing trim. I’d like to make this process easier by scripting it, i.e. choose a file, enter a start time, enter an end time and trim the file, but I don’t understand the dictionary that well. The two items in the dictionary I was thinking I could use are select and trim.

select‚v : Select a range of time
select reference : the movie whose selection is to be set
[at integer] : starting time of the selection
[to integer] : end time of the selection

trim‚v : Remove all content before and after the current selection
trim reference : movie

My questions are:

  1. Is what I’m looking to do possible in AppleScript?
  2. If so, am I looking at the right dictionary items?
  3. If so, how do I use these items in a script?

Any help would be appreciated.



Model: iMac G5
Browser: Safari 412.2
Operating System: Mac OS X (10.4)

Play around with the following script:

tell application “QuickTime Player”

	close front window
end try
choose file with prompt "Choose audio file:"
open result

	display dialog "Cut how many seconds off beginning?" default answer ""
	set cut_begin to the text returned of the result
	if cut_begin is not "" then exit repeat
end repeat

	display dialog "Cut how many seconds off end?" default answer ""
	set cut_end to the text returned of the result
	if cut_end is not "" then exit repeat
end repeat

set begin_movie to 0
set end_movie to duration of movie 1

set begin_selection to (time scale of movie 1) * cut_begin
set end_selection to (time scale of movie 1) * cut_end

select movie 1 at (begin_movie + begin_selection) to (end_movie - end_selection)

trim movie 1

save movie 1 in (path to desktop as Unicode text) & name of movie 1 & "_copy"

end tell