I’m trying to create a drag&drop application that cut a portion of a movie (from start to x)
on open file
tell application “QuickTime Player 7”
activate
open currentFile
set i to 0
set o to 10000
select at i to o
cut document 1
end tell
end open
it dosen’t cut anything… (without the cut line the selection is correctly made) HELP
Also is it possible to use the frame class to use frames to set i and o variables?
the parameter of on open is a list of files
so a repeat loop is needed to process one file after another.
the select command needs also the document reference as the direct parameter
Try this, the script works as applet too and checks the kind of the file
Probably you still have to add code to save and close the file
on run
open (choose file with multiple selections allowed)
end run
on open theFiles
tell application "QuickTime Player 7"
stop every document
activate
end tell
repeat with aFile in theFiles
try
tell application "System Events"
set quickTimeFile to QuickTime file (aFile as text)
set fileIsMovie to kind of quickTimeFile contains "movie"
end tell
if fileIsMovie then
tell application "QuickTime Player 7"
open aFile
set input to 0
set output to 10000
tell document 1
select it at input to output
cut
end tell
end tell
end if
end try
end repeat
end open
I’ve tried your script but QT dosn’t actually cut the portion selected
I have tried to use trim instead of cut the selection is really trimmed (but in this manner I have to make selection beetween 10000 and the end of the video, don’t know how to do that…)
Can’t find the delete action (edit menu in QT) in the QT dictionary
on run
open (choose file with multiple selections allowed)
end run
on open theFiles
set destinationFolder to choose folder
tell application "QuickTime Player 7"
stop every document
activate
end tell
repeat with aFile in theFiles
try
tell application "System Events"
set quickTimeFile to QuickTime file (aFile as text)
set fileIsMovie to kind of quickTimeFile contains "movie"
set {name:fileName, name extension:fileExtension} to quickTimeFile
set baseName to text 1 thru ((get offset of "." & fileExtension in fileName) - 1) of fileName
end tell
if fileIsMovie then
tell application "QuickTime Player 7"
open aFile
set input to 100000
tell document 1
set output to duration
select at input to output
trim
save self contained in file ((destinationFolder as text) & baseName & ".mov")
close
end tell
end tell
end if
end try
end repeat
end open
if you don’t want to change the file format, just write
save
instead of the save self contained line
or
close saving yes
instead of the save and close line
export aFile does not work because there is already a reference to the document (the tell block)
and aFile is an alias specifier not a QuickTime document