Jump to content
Server Maintenance This Week. ×

Applescript not working after upgrade


This topic is 564 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I have been using FileMaker 16 on Mac OS 10.14 for many years. One of the scripts I have been using used an Applescript step to control iTunes and it worked without issue all that time. I recently upgraded to FileMaker 19 and OS 12.5 (and Music instead of iTunes). The script no longer works, or works only partially. The script is:

"-- set image path" & ¶ &
"tell application \"Finder\"" & ¶ &
	"set pathToImage to (\"OTunes A:_AlbumArt.jpg\")" & ¶ &
	"set currentArtwork to (read file pathToImage as data)" & ¶ &
"end tell" & ¶ &

"try" & ¶ &

"-- setup Music" & ¶ &
"tell application \"Music\"" & ¶ &
	"activate" & ¶ &
	"reopen" & ¶ &
	"set current encoder to encoder \"AIFF Encoder\"" & ¶ &

"-- clear any tracks from playlist" & ¶ &
	"delete tracks of playlist \"_Convert\"" & ¶ &

"-- import track" & ¶ &
	"set newFile to alias (\"" & $filePath & "\")" & ¶ &
	"add newFile to playlist \"_Convert\"" & ¶ &
	"set sel to track 1 in playlist \"_Convert\"" & ¶ &

"-- add Music tags" & ¶ &
	"set album of sel to \"Music Library\"" & ¶ & 
	"set artist of sel to \"" & Songs::oTunesArtist & "\"" & ¶ & 
	"set comment of sel to \"" & $comments & "\"" & ¶ & 
	"set genre of sel to \"" & Songs::genre & "\"" & ¶ & 
	"set name of sel to \"" & Songs::title & "\"" & ¶ & 
	"set rating of sel to \"100\"" & ¶ &
	"set composer of sel to \"Mastered\"" & ¶ &

"-- grab song length" & ¶ &
	"set songDuration to duration of sel" & ¶ &
	"set num_minutes to songDuration div 60" & ¶ &
	"set num_seconds to songDuration mod 60 as integer" & ¶ &
	"set songDuration to num_minutes & \":\" & (text -2 through -1 of (\"0\" & num_seconds)) as string" & ¶ &

"-- set AIFF save location" & ¶ &	
	"set uD to (\"OTunes A:_All Wesbite AIF:_Add to Website\")" & ¶ &
	"if uD is false then error number -128" & ¶ &

"-- convert track to AIF" & ¶ &	
	"set new_track to item 1 of (convert sel)" & ¶ &
	"set loc to (get location of new_track)" & ¶ &
	"set dbid to new_track's database ID" & ¶ &
	"set name_hold to \"" & $cleanedTitle & "-company\"" & ¶ &
	"set name of new_track to name_hold" & ¶ &

"-- change ID3 tags" & ¶ &
	"set artist of new_track to \"Company\"" & ¶ &
	"set album of new_track to \"www.company.com\"" & ¶ &
	"set rating of new_track to 0" & ¶ &
	"set grouping of new_track to \"\"" & ¶ &
	"set composer of new_track to \"\"" & ¶ &
	"set lyrics of new_track to \"\"" & ¶ &
	"set track number of new_track to 0" & ¶ &
	"set track count of new_track to 0" & ¶ &
	"set disc number of new_track to 0" & ¶ &
	"set disc count of new_track to 0" & ¶ &
	"set data of artwork 1 of new_track to currentArtwork" & ¶ &

"-- move the file to new location" & ¶ &
	"do shell script \"mv \" & (quoted form of POSIX path of loc) & \" \" & (quoted form of POSIX path of uD as string)" & ¶ &

"-- delete the track" & ¶ &
	"delete new_track" & ¶ &

"-- set WAV save location" & ¶ &
	"set uD to (\"OTunes A:_All Subpublisher WAV:_Add To Online\")" & ¶ &
	"if uD is false then error number -128" & ¶ &

"-- set WAV encoder" & ¶ &	
	"set current encoder to encoder \"WAV Encoder\"" & ¶ &

"-- convert to WAV" & ¶ &
	"set new_track to item 1 of (convert sel)" & ¶ &
	"set loc to (get location of new_track)" & ¶ &
	"set dbid to new_track's database ID" & ¶ &
	"set name_hold to \"" & $cleanedTitle & "company\"" & ¶ &
	"set name of new_track to name_hold" & ¶ &
	"-- change ID3 tags" & ¶ &
	"set artist of new_track to \Company\"" & ¶ &
	"set album of new_track to \"www.company.com\"" & ¶ &
	"set rating of new_track to 0" & ¶ &
	"set grouping of new_track to \"\"" & ¶ &
	"set composer of new_track to \"\"" & ¶ &
	"set track number of new_track to 0" & ¶ &
	"set track count of new_track to 0" & ¶ &
	"set disc number of new_track to 0" & ¶ &
	"set disc count of new_track to 0" & ¶ &

"-- move the file to new location" & ¶ &
	"do shell script \"mv \" & (quoted form of POSIX path of loc) & \" \" & (quoted form of POSIX path of uD as string)" & ¶ &

"-- delete the track" & ¶ &
	"delete new_track" & ¶ &

"-- reset encoder" & ¶ &	
	"set current encoder to encoder \"AIFF Encoder\"" & ¶ &

"-- clear track from playlist" & ¶ &
	"delete tracks of playlist \"_Convert\"" & ¶ &

"end tell" & ¶ &

"tell application \"Finder\"" & ¶ &
    "set the clipboard to songDuration" & ¶ &

"end tell" & ¶ &

"end try"

The script will always get as far as importing the track. Sometimes it will add the track to the playlist "_Convert", but not always. Occasionally, it will set the tags and once or twice it got as far as converting the track to aif and setting that new track's tags. The script DOES work if I run it from Script Editor, though I have to change so many things - formatting and FM references - that it's not quite a one-to-one comparison. I also have the following set in the Security and Privacy tabs:

ACCESIBILITY

  • FileMaker Pro
  • Script Editor

FULL DISK ACCESS

  • FileMaker Pro
  • Script Editor

MEDIA & APPLE MUSIC

Nothing here, but I've never been asked to allow access.

AUTOMATION

  • FileMaker Pro
    • Finder
    • Music

I've tried everything I can think of but cannot figure this out. Any ideas?

Thanks!

Link to comment
Share on other sites

This topic is 564 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.