Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator & Music App - 'Import Audio Files' and -1712 error message.

Has anyone encountered the -1712 error message (see screenshot below) when using the 'Import Audio Files' action in Automator (MacBook Pro 2019, OS. 11.1Big Sur).


I have a very simple script (see screenshot below) running in Automator to import folders of .wav files into Music (iTunes) then convert these to Apple Lossless format. (I'm aware this can be done manually by other means through the Music menus but this isn't what I need).


I am trying to automate this process as I have hundreds of folders of .wav music files to import and wish to speed up the process as well as do some further processing on the files with Automator, once in Music.


The script does work as intended - however if there are a larger number of files in the folder, or the files are of a larger size, Automator throws up the -1712 error message, then continues to process the files but drops out before completing the rest of the Automator script i.e. the script never reaches the "Set Info of Music Songs" step in the script.


The error message appears to be a 'timeout' issue, whereby it's taking longer than the 'timeout period' allocated to process the files and thereby dropping out.


Has anyone else had this issue or know of a solution? – Any help would be appreciated.



MacBook Pro 16″, 11.0

Posted on Jan 4, 2021 3:43 PM

Reply
Question marked as Best reply

Posted on Jan 11, 2021 11:12 AM



>You need to look at the dictionary to understand the terms that Music.app expects (File -> Open Dictionary, then select the app).


I was aware of the dictionary thanks-I was just trying to get my head around the properties syntax.


>You might have been confused by the fact I used almost identical names for my variables as the properties they're assigned to. That's just a convention, and your variable can be anything at all:


This wasn't the issue as it turns out, my error as I hadn't put a space in where I should've done initially!


>The trickier issue is deleting them from the Music library - as you've seen, when you convert a track like this you get both the original .wav and the lossless copy of the track in your library.

...

>Note that this could delete other tracks that have no artist data, so be careful. You can refine this, though, by adding other clauses


>tell application "Music"

delete (every track whose artist is "" and kind is "WAV audio file")

end tell


This trick worked perfectly well for me as I don't have keep any .wav files in this music library.


The script works absolutely great for me now, in terms of:

getting a folder of .wav files

importing these into the music application

converting these to apple lossless

deleting the redundant .wav files from the music library.


I have now adopted your code (much appreciated) and incorporated this within a short Automator script using a 'Run AppleScript' action, having looked at other examples. This allows me to drop a folder of files onto the app for processing. It also now gets around the Automator 'time-out' error -1712.

You will see from the code that I have simply given the album name a placeholder name – the reason being I still need to 'Set the Info of the Music Songs' and artwork, so it's easier to do it from a single interface once converted and in Music, rather than asking for these individually when the AppleScript code runs. Plus I also need to run a separate script that embeds the track numbering for the album.

I'm currently trying to work out how to pass the required information from the AppleScript code into 'Set the Info of the Music Songs' Automator action...but this is something to keep me occupied.


As you are probably aware, it's significantly quicker to encode files external to music by selecting the files from a Finder > Control click > Encode Selected Audio Files, but this requires more clicking and selection from menus.

The Automator & AppleScript code may not be the fastest or most elegant solution and can probably be refined, but it works and in any case, this is all new to me and the start of a fruitful journey hopefully. Many Thanks.


on run {input, parameters}
	
	--get the source files
	set source_files to {}
	repeat with f in input
		set end of source_files to contents of f
	end repeat
	
	set _albumname to "Lossless"
	
	tell application "Music"
		
		-- save the current encoder settings to restore later	
		set _prev_enc to (get current encoder)
		
		-- set the app to use lossless
		set current encoder to encoder "Lossless Encoder"
		
		-- loop through the files
		with timeout of 3600 seconds -- one hour limit to import the folder
			
			--set new_tracks to add source_files
			set new_tracks to convert source_files
		end timeout
		
		-- update the imported tracks with the album/artist info
		repeat with each_track in new_tracks
			tell each_track
				set album to _albumname
			end tell
		end repeat
		
		-- clean up and delete .wav files from music library
		tell application "Music"
			delete (every track whose artist is "" and kind is "WAV audio file")
		end tell
		
		set current encoder to _prev_enc
	end tell
	
	return source_files
	return input
end run


Similar questions

6 replies
Question marked as Best reply

Jan 11, 2021 11:12 AM in response to Camelot



>You need to look at the dictionary to understand the terms that Music.app expects (File -> Open Dictionary, then select the app).


I was aware of the dictionary thanks-I was just trying to get my head around the properties syntax.


>You might have been confused by the fact I used almost identical names for my variables as the properties they're assigned to. That's just a convention, and your variable can be anything at all:


This wasn't the issue as it turns out, my error as I hadn't put a space in where I should've done initially!


>The trickier issue is deleting them from the Music library - as you've seen, when you convert a track like this you get both the original .wav and the lossless copy of the track in your library.

...

>Note that this could delete other tracks that have no artist data, so be careful. You can refine this, though, by adding other clauses


>tell application "Music"

delete (every track whose artist is "" and kind is "WAV audio file")

end tell


This trick worked perfectly well for me as I don't have keep any .wav files in this music library.


The script works absolutely great for me now, in terms of:

getting a folder of .wav files

importing these into the music application

converting these to apple lossless

deleting the redundant .wav files from the music library.


I have now adopted your code (much appreciated) and incorporated this within a short Automator script using a 'Run AppleScript' action, having looked at other examples. This allows me to drop a folder of files onto the app for processing. It also now gets around the Automator 'time-out' error -1712.

You will see from the code that I have simply given the album name a placeholder name – the reason being I still need to 'Set the Info of the Music Songs' and artwork, so it's easier to do it from a single interface once converted and in Music, rather than asking for these individually when the AppleScript code runs. Plus I also need to run a separate script that embeds the track numbering for the album.

I'm currently trying to work out how to pass the required information from the AppleScript code into 'Set the Info of the Music Songs' Automator action...but this is something to keep me occupied.


As you are probably aware, it's significantly quicker to encode files external to music by selecting the files from a Finder > Control click > Encode Selected Audio Files, but this requires more clicking and selection from menus.

The Automator & AppleScript code may not be the fastest or most elegant solution and can probably be refined, but it works and in any case, this is all new to me and the start of a fruitful journey hopefully. Many Thanks.


on run {input, parameters}
	
	--get the source files
	set source_files to {}
	repeat with f in input
		set end of source_files to contents of f
	end repeat
	
	set _albumname to "Lossless"
	
	tell application "Music"
		
		-- save the current encoder settings to restore later	
		set _prev_enc to (get current encoder)
		
		-- set the app to use lossless
		set current encoder to encoder "Lossless Encoder"
		
		-- loop through the files
		with timeout of 3600 seconds -- one hour limit to import the folder
			
			--set new_tracks to add source_files
			set new_tracks to convert source_files
		end timeout
		
		-- update the imported tracks with the album/artist info
		repeat with each_track in new_tracks
			tell each_track
				set album to _albumname
			end tell
		end repeat
		
		-- clean up and delete .wav files from music library
		tell application "Music"
			delete (every track whose artist is "" and kind is "WAV audio file")
		end tell
		
		set current encoder to _prev_enc
	end tell
	
	return source_files
	return input
end run


Jan 7, 2021 10:54 AM in response to Camelot

Sincere thanks again for your considerate and detailed response as well as providing an AppleScript example to work with-I wasn't expecting this! however this was much appreciated as it inspired me to try some AppleScripting (after giving myself a quick crash course) and looking at other examples of these for solutions as well.


Your script worked well for adding and converting .wav files to apple lossless.


I also managed to add some code to put these files into a playlist (amazingly) although trying to add other user input metadata to the converted files like "year" or "album artist" which I thought would be simple, following your example, didn't work* i.e.


set _albumartist to text returned of (display dialog "Enter the albumartist:" default answer "" buttons {"Cancel", "OK"} default button 2)
.
.
set artist to _artist
set album to _albumname
*set albumartist to _albumartist*

but I may not be understanding something related to these properties


However, still persevering with this and endeavouring to get my head around Apple scripting for now.


For the purposes of the original project and with this particular part, all I was attempting to do was:


  1. import .wav files to Music from user selected folder
  2. convert to apple lossless
  3. add metadata (artist, album, genre, year)
  4. delete the imported .wav files from the Music library


That was it really - I started to have a look at code for deleting files but again it got a bit complicated for me and I wasn't sure I was necessarily doing the right thing, or in the right place, which could have had other consequences for the music library therefore decided not to get too ahead of myself.


I was working along the lines generally of:

tell application "Finder" to delete (files of ??? whose name extension = "wav")

But then wasn't sure how to 'identify' the .wav files imported into the Music app library and was also wondering whether Track/Database ID was a better way to go. Having decided I'm a bit out of my depth at this point in time, I may have to rely on your generous nature to point me in the right direction again with the last issue:

4. delete the .wav files from the Music library


Thanks in advance.

Jan 5, 2021 6:49 AM in response to Camelot

Camelot - many thanks for your swift reply, this is much appreciated and only reinforces my suspicions and your comments regarding Automator.


I ran a few more tests on different batches of files to see if there was any common issue and sure enough the process timed out at the 60 second mark on each occasion with the -1712 error but with no further detail. See screenshot below of Automator log:



As you indicated I don't believe there is any way of overriding the Timeout limits as far as I can see and the limitations of Automator actions (the 'Import Audio Files' action can't be deconstructed further) prevent me from creating a script that will enable me to do what I was intending.


Unfortunately, I am not aufait with AppleScript to code something but could probably pick this up. I have seen some very old posts on previous discussions whereby a small piece of AppleScript code can be inserted to re-set a 'timeout' to something more useful, but not sure if this would be feasible in this case – however it's a trade off now to do this manually or find some other workarounds . Unfortunately, splitting the files into batches and importing these also raises other issues for me in terms of collating the files, (lack of 'Tag' information with .wav files) and for further processing, due to the way Music functions. It would also be preferable to import a folder of music tracks per album, in one operation rather than splitting these up.


You would think it would be easy to automate importing a group of .wav files into music, convert these files to Apple Lossless and pack these into their own folder and at the same time remove the redundant .wav files from the music library - essentially all I was trying to do but perhaps I'm missing something here. "It's never that simple" as someone said...


I may have a go at trying some of my own AppleScript, if I can get to grips with this and inserting into Automator and see if I can get a workaround.


I have a call back today from Apple customer support again later today on this issue, however you managed to pack into your post more useful information than I gained from an hour and a half on the phone to Apple support previously.

Many thanks again.


Jan 4, 2021 4:49 PM in response to Hubhal

Debugging and troubleshooting is not one of Automator's strong suits. Some might say it's sorely lacking... :)


You might get more detail from the log. At the very least this should show more detail of where it's failing.


-1712 is a classic timeout error code, so you're probably on the right track. The timestamps in the log might make it more obvious - look for nice round numbers.


Ultimately, though, if it is a timeout issue, you may need to refactor your workflow. There's no user control (at least that I'm aware of) to override timeout values. Therefore if it's taking a long time to transcode all your files you're going to trip the timeout. The simplest workaround is likely to break the transcoding into batches (the timeout would apply to each action, so as long as each batch executes before the timeout you should be OK - assuming each transcode takes 1 minute and you have 500 files, it's the difference between triggering 500 one-minute actions (which will work within the timeout limits) vs. a single 500-minute one (which will likely fail).


The biggest problem here, though, is that looping in Automator is a PITA. At that point it's probably worth finding another path - either AppleScript or shell are possible candidates.

Jan 6, 2021 10:38 AM in response to Hubhal

> I have seen some very old posts on previous discussions whereby a small piece of AppleScript code can be inserted to re-set a 'timeout' to something more useful, but not sure if this would be feasible in this cas


I think you're talking about the with timeout... command, but I don't think that would help here. That adjusts AppleScript's timeout, but only for the steps it takes. Automator has its own (immutable?) for each of its actions.


> You would think it would be easy to automate importing a group of .wav files into music, convert these files to Apple Lossless and pack these into their own folder and at the same time remove the redundant .wav files from the music library - essentially all I was trying to do but perhaps I'm missing something here. "It's never that simple" as someone said...


You're right, it's never that simple, but it also doesn't sound too hard - but the devil is in the details.


It's actually pretty easy to get Music.app to import a track, and convert from .wav to a lossless format (although you're already losing fidelity from the .wav format, but I'll pass on that for now). More of an issue is the metadata - for example grouping the tracks by artist/album. Where is this data coming from? If there's a clearly defined path for that (even if prompting the user, analyzing the folder structure, or something), then an AppleScript can probably handle the task. Happy to skin this out for you if you can provide more details.


As a starting point, here's a simple AppleScript that prompts you for a folder and imports the files as Apple Lossless after prompting for a Album and Artist name:


--  prompt the user for the artist/album info
-- (this can be changed to any logic you like)
set _artist to text returned of (display dialog "Enter the artist name:" default answer "" buttons {"Cancel", "OK"} default button 2)
set _albumname to text returned of (display dialog "Enter the album name:" default answer "" buttons {"Cancel", "OK"} default button 2)

-- get a list of files to import
set source_files to my GetSourceFiles()

tell application "Music"
	-- save the current encoder settings to restore later	
	set _prev_enc to (get current encoder)
	-- set the app to use lossless
	set current encoder to encoder "Lossless Encoder"
	
	-- loop through the files
	with timeout of 3600 seconds -- one hour to import the folder
		set new_tracks to convert source_files
	end timeout
	-- update the imported tracks with the album/artist info
	repeat with each_track in new_tracks
		tell each_track
			set artist to _artist
			set album to _albumname
		end tell
	end repeat
	
	-- and clean up
	set current encoder to _prev_enc
end tell


on GetSourceFiles()
	-- ask the user for the folder to process
	set source_dir to (choose folder with prompt "Select the tracks folder")
	
	-- get the Finder to return a list of files
	set f to {}
	tell application "Finder"
		set f to (every file of source_dir whose name extension is "wav") as alias list
	end tell
	return f
end GetSourceFiles


You should be able to paste this into a new Script Editor document and click Run.

Jan 7, 2021 5:12 PM in response to Hubhal

> but I may not be understanding something related to these properties


You need to look at the dictionary to understand the terms that Music.app expects (File -> Open Dictionary, then select the app).


In the case of a track's album artist, the property is: album artist


So your script should look like:


set album artist to _albumartist


You might have been confused by the fact I used almost identical names for my variables as the properties they're assigned to. That's just a convention, and your variable can be anything at all:


set foo to text returned of (display dialog "Enter the ablum artist:" default answer "")
...
set album artist to foo


>I started to have a look at code for deleting files but again it got a bit complicated for me and I wasn't sure I was necessarily doing the right thing, or in the right place, which could have had other consequences for the music library therefore decided not to get too ahead of myself


There are two parts to this. One is the physical file on disk, the other is Music.app's reference to it in the Library/playlist.


The good news is that the script already has a list of the files that it importing in the source_files variable, so it's easy to delete the files after the import has finished:


tell application "Finder"
  delete source_files
end tell


The trickier issue is deleting them from the Music library - as you've seen, when you convert a track like this you get both the original .wav and the lossless copy of the track in your library.

For this you might rely on a trick that the .wav files have no artist/album data, as such they all end up in a 'Unknown Artist' bucket, so it could be as simple as:


tell application "Music"
	delete (every track whose artist is "")
end tell


Note that this could delete other tracks that have no artist data, so be careful. You can refine this, though, by adding other clauses

tell application "Music"
	delete (every track whose artist is "" and kind is "WAV audio file")
end tell


Automator & Music App - 'Import Audio Files' and -1712 error message.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.