Ideal for Sony Ericsson phone owners who use voice memos and send them via bluetooth.
Based on some other scripts I found here.
on adding folder items to this_folder after receiving added_items
set destination_folder to "" -- change to your preferred target location
set itemList to added_items
tell application "QuickTime Player"
launch
my supressAutoPlay(true) -- make sure movies set to auto play do not do that
end tell
repeat with x from 1 to count of itemList
copy item x of itemList as string to theFile
if isAMR(theFile) then
set aMovie to theFile
tell application "QuickTime Player"
open aMovie
rewind
select none
if saveable of document 1 is true then
-- get properties of the movie
set window_bounds to bounds of window 1
tell document 1
set orig_name to name
set annNames to name of annotations
set annValues to full text of annotations
tell application "Finder" to set orig_comments to comment of file aMovie
end tell
-- get name of movie from file name
set nmExt to my getName_andExtension(aMovie)
set file_name to item 1 of nmExt
-- copy and paste the movie into a new movie container
tell application "QuickTime Player"
tell document orig_name
rewind
select all
copy
end tell
make new document
tell document 1
paste
rewind
select at 0 to 0
end tell
end tell
close document orig_name saving no
-- reposition the movie window to the original movie's position
set bounds of window 1 to window_bounds
-- set annotations to annotations from the original movie
my dupAnns(1, annNames, annValues, file_name)
-- save the movie to the destination folder
tell application "Finder"
set theDate to creation date of file theFile --date string of theDate --hours of theDate
set theSize to size of file theFile as string
end tell
set new_file to (destination_folder & file_name & " " & theSize & " " & date string of theDate & " " & ".mov") as string
--display dialog new_file
save self contained document 1 in file new_file
close document 1 saving no
-- set its comments and date to those from original file
tell application "Finder"
set comment of file new_file to orig_comments
set modification date of file new_file to modification date of file theFile
end tell
-- set the label color from blue to green indicating a successful operation
tell application "Finder" to tell file aMovie to set label index to 6
else
display dialog "This movie has previously been set so that it cannot be copied, edited, or saved." & return & return & "Would you like to close this movie and continue processing the rest of the movies or stop the script?" buttons {"Close and Continue", "Stop"} default button 2
set button_entered to button returned of result
if button_entered is "Stop" then
return
else
close document 1 saving no
end if
end if
end tell
-- display dialog theFile --as string
end if
end repeat
end adding folder items to
on isAMR(theFile)
set fileName to theFile as string
set item_info to info for file fileName
tell item_info
set is_folder to folder
set ne to name extension
set its_kind to kind
set file_type to file type
end tell
if ne is "amr" then
return true
end if
return false
end isAMR
on supressAutoPlay(status_flag)
tell application "QuickTime Player"
set ignore auto play to the status_flag
set ignore auto present to the status_flag
end tell
end supressAutoPlay
on getName_andExtension(F)
set F to F as string
set {name:Nm, name extension:Ex} to info for file F
if Ex is missing value then set Ex to ""
if Ex is not "" then
set Nm to text 1 thru ((count Nm) - (count Ex) - 1) of Nm
set Ex to "." & Ex
end if
return {Nm, Ex}
end getName_andExtension
on dupAnns(movie_name, annNames, annValues, file_name)
tell application "QuickTime Player"
tell document movie_name
repeat with i from 1 to (count of annNames)
if exists annotation (item i of annNames) then
set full text of annotation (item i of annNames) to (item i of annValues)
else
make new annotation with properties {name:(item i of annNames), full text:(item i of annValues)}
end if
end repeat
if "Full Name" is not in annNames then
make new annotation with properties {name:"Full Name", full text:file_name}
end if
end tell
end tell
end dupAnns