Le 15 avr. 2008 à 15:59, David A a écrit :
Thanks Yvan!
I made some corrections based on what you said. I created the following:
set destination_folder to choose folder
set these_items to choose file with multiple selections allowed
repeat with this_item in these_items
beep 1
set item_info to info for this_item
set file_name to name of item_info
if name extension of item_info is in {"mp3", "wav"} then
tell application "QuickTime Player"
launch
export file_name to ((destination_folder as text) & "new.mov") as "QuickTime hinted movie"
end tell
end if
end repeat
However I am now getting an error message:
QuickTime Player got an error: Can’t get alias "Macintosh HD:Users:alt10hof:Desktop:qt_test:major_funk.mp3".
That mp3 file is the file I'm trying to export, and I can't figure out why it can't "get" it.
-David
Hello
I 'm not acustomed to QuickTime Player.
I made a few tests with your script.
Here is the execution report:
tell current application
choose folder
alias "Caviar Macintosh HD:Users:yvankoenig:Documents:"
choose file with multiple selections allowed
{alias "Caviar Macintosh HD:Users:yvankoenig:Desktop:01 fire_revisited.mp3"}
beep 1
info for alias "Caviar Macintosh HD:Users:yvankoenig:Desktop:01 fire_revisited.mp3"
{name:"01 fire_revisited.mp3", creation date:date "mercredi 22 novembre 2006 21:26:38", modification date:date "mercredi 22 novembre 2006 21:26:38", icon position:{0, 0}, size:3.76891E+5, folder:false, alias:false, package folder:false, visible:true, extension hidden:false, name extension:"mp3", displayed name:"01 fire_revisited.mp3", default application:alias "Caviar Macintosh HD:Applications:iTunes.app:", kind:"Fichier audio MP3", file type:"file creator:"type identifier:"public.mp3", locked:false, busy status:false, short version:"", long version:""}
end tell
tell application "QuickTime Player"
launch
current application
export "01 fire_revisited.mp3" to "Caviar Macintosh HD:Users:yvankoenig:Documents:new.mov" as "QuickTime hinted movie"
end tell
You may see that I got no error message but I got nothing in the destination folder.
My guess is that you don't use the correct operand.
The dictionary claims that:
we may export a movie or a track but you are trying to export a string
we may export to a file but you are exporting to a string too.
I tried to create the new.mov file before exporting into it:
set destination_folder to choose folder
set these_items to choose file with multiple selections allowed
set i to 1
repeat with this_item in these_items
beep 1
tell application "System Events" to tell disk item (this_item as text)
set name_extension to name extension
set file_name to name
end tell
if name_extension is in {"mp3", "wav"} then
set newMov to "new" & i & ".mov"
set newFile to (destination_folder as Unicode text) & newMov
tell application "System Events"
if exists file newFile then delete file newFile
make new file at end of destination_folder with properties {name:newMov}
end tell
set newFile to newFile as alias as alias
tell application "QuickTime Player"
launch
export file_name to newFile as "QuickTime hinted movie"
end tell
set i to i + 1
end if
end repeat
tell current application
choose folder
alias "Caviar Macintosh HD:Users:yvankoenig:Documents:"
choose file with multiple selections allowed
{alias "Caviar Macintosh HD:Users:yvankoenig:Desktop:01 fire_revisited.mp3"}
beep 1
end tell
tell application "System Events"
get name extension of disk item "Caviar Macintosh HD:Users:yvankoenig:Desktop:01 fire_revisited.mp3"
"mp3"
get name of disk item "Caviar Macintosh HD:Users:yvankoenig:Desktop:01 fire_revisited.mp3"
"01 fire_revisited.mp3"
exists file "Caviar Macintosh HD:Users:yvankoenig:Documents:new1.mov"
true
delete file "Caviar Macintosh HD:Users:yvankoenig:Documents:new1.mov"
make new file at end of alias "Caviar Macintosh HD:Users:yvankoenig:Documents:" with properties {name:"new1.mov"}
file "Caviar Macintosh HD:Users:yvankoenig:Documents:new1.mov"
end tell
tell application "QuickTime Player"
launch
current application
export "01 fire_revisited.mp3" to alias "Caviar Macintosh HD:Users:yvankoenig:Documents:new1.mov" as "QuickTime hinted movie"
end tell
Always no error but the created file is desperately empty.
So, I assumes that the problem is in the nature of the given operand : file_name is not the correct one.
Yvan KOENIG