wav to m4a via quickaction

Dear friends,
I am trying to create a quick action (activated by right click) for WAV to m4a conversion process: I discovered that quicktime player has an option File->Export as-> Audio only…->

I want to imitate the clicks on the menu but cannot “click” on the “Audio only…” while File and Export as are “clickable” via Applescript.

This is the script I am trying to run - the line with “->” gives an error System Events got an error: Can’t get menu item “Audio only…” of menu item “Export as” of menu “File” of menu bar 1 of process “QuickTime Player”.:

on run {input, parameters}
	
	tell application "System Events"
		tell process "QuickTime Player"
			set frontmost to true
			click menu "File" of menu bar 1
			click menu item "Export as" of menu "File" of menu bar 1
			-> click menu item "Audio only..." of menu item "Export as" of its menu "File" of menu bar 1
			
			
		end tell
	end tell
	
	return input
end run

I will highly appreciate any ideas regarding the general task and the error in particular.
Thanks :slight_smile:

You were close to the target:


on run {input, parameters}
	tell application "System Events" to tell process "QuickTime Player"
		set frontmost to true
		click menu "File" of menu bar 1
		click menu item "Export as" of menu "File" of menu bar 1
		click menu item "Audio Only…" of menu "Export as" of menu item "Export as" of menu "File" of menu bar 1
	end tell
	return input
end run

Belatedly, you might try something like this:
[format]
Service accepts: audio files in Finder

Get Selected Finder Items

Import Audio Files (using AAC encoder)[/format]

Check the ‘delete source files after encoding’ at your peril.

Test it out on an unsuspecting wave file and if it works, save away. By default, it will save the new file in the Unknown Artist > Unknown Album folder along with the rest of your itunes tracks. If your system is more modern than mine, it should be wherever Music stores its files.

By the way, itunes can convert files manually using File > Convert > Create AAC Version.