Scripting QuickTime to save an audio file

I have had a AppleScript that saved an audio recording made in Quicktime in a specific folder.
After upgrading to Big Sur the script fails because QuickTime “can’t create the file”.

any help would be appreciated

–I get the following info From a database in Filemaker pro
–I am manually setting these variables for the purpose of debugging

set database_folder to “MacBook HD:Users:Kevin:Documents:allyn database stuff:”
set toBurnSound to “KevinMiller8888.aiff”

–The following section sets the location for where I want to save the file

set targetLocation to database_folder & “savedaudio:”
set myFilename to targetLocation & toBurnSound
set placetosaveFile to a reference to file myFilename
set nothingwentwrong to false
– will need to put in filemaker ability to pass businesscomment to this script
set businesscomment to “Property of Allyn Miller,MFT. Do not distribute without express permission”

tell application “QuickTime Player”

tell application "System Events"
	delay 1
	tell application process "QuickTime Player" to tell window 1 to ¬
		click UI element 3 --  (Stop BUTTON) OF RECORDING WINDOW
end tell

	set newRecordingDoc to first document whose name = "Untitled"
	export newRecordingDoc in placetosaveFile using settings preset "Audio Only"
	close newRecordingDoc without saving
	set nothingwentwrong to true
on error
	set nothingwentwrong to false
end try
delay 1

end tell
display dialog nothingwentwrong

Model: MacBook Pro (Retina, 13-inch, Late 2013)
AppleScript: 2.7
Browser: Safari 605.1.15
Operating System: macOS 10.14

Most likely, the destination file should be existing file before exporting to it. This is Apple approach for exporting documents last years. At least, with many other Apple apps. So, before exporting to destination file, tell to to make this empty file with given name.

tell application "Finder" to try
	make new file at folder targetLocation with properties {name:toBurnSound}
end try

And, file reference always is better to create inside tell block of application:

export newRecordingDoc in file myFilename using settings preset "Audio Only"

NOTE: myFilename is full HFS path, so this variable’s name myFileHFSpath is closer to what it is. To understand the code for others, as well as yourself in the future, it is always best to give variables names that represent the essence of what those variables represent.

I do something similar except I use ‘open for access’ to set up the destination file

[format]set placetosaveFile to (choose file name default name “audio.m4a”) as text
tell me to close access (open for access placetosaveFile)[/format]

But, what I really wanted to point out was that there is a built-in alternative to using system events to stop the recording — stop. The following will record six seconds of audio.

[format] set new_recording to (new audio recording)
tell new_recording
delay 6
end tell[/format]

Also, I don’t think ‘reference to’ is required. This all said, I cannot test on Big Sur so take with a grain of salt.


even though Stop, Pause, and resume are in the QuickTime dictionary, It no longer works in Big Sur



that worked well

thank you


That’s disappointing to hear.