Script Ran in Monterey but Error in Sonoma

I had this script running successfully on my Mac mini when it was on Monterey (latest version), but now running Sonoma (also latest version) it throws an error (see screenshot attached).
Any ideas?

tell application id "com.apple.Finder" to duplicate file POSIX file ¬
	"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/abook.sqlite" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing

tell application id "com.apple.Finder" to duplicate file POSIX file ¬
	"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/history.sqlite" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing

tell application id "com.apple.Finder" to duplicate file POSIX file ¬
	"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/bookmarks.html" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing

tell application id "com.apple.Finder" to duplicate file POSIX file ¬
	"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/favicons.sqlite" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing

tell application id "com.apple.Finder" to duplicate file POSIX file ¬
	"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/places.sqlite" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing

tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
	"/Users/margehomer/Library/Application Support/ChronoSync/Tasks" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Backup Scripts/ChronoSync Tasks" with replacing

tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
	"/Users/margehomer/Library/Application Support/XMenu/Custom" to the folder ¬
	POSIX file "/Users/margehomer/Documents/Mac Mini Specific/XMenu Sync" with replacing

display notification "Completed Successfully!" with title "Pre Backup AppleScript"

delay 1

Screenshot

Check you have allowed the app full disk access via the Accessibility features, Ventura changed a number of security permissions so make sure you go to System Settings > Privacy & Security > Full Disk Access and make sure you app is added in there and enabled.

Mark, tried adding to System Settings > Privacy & Security > Full Disk Access as well as System Settings > Privacy & Security > Accessibility, no luck.

I’ll need to check where it may have been added on my M1, 2020 MacBook Pro and see if I need to add it to the same location on my 2018 Intel Mac mini.

Strange issues sometimes.

Just checked and on the MacBook Pro this “Pre Backup AppleScript” is listed in System Settings > Privacy & Security > Files and Folders, but there doesn’t seem to be a way to add it there. In System Settings > Privacy & Security > Full Disk Access there’s a little (+) sign at the bottom, but not in System Settings > Privacy & Security > Files and Folders.

Stuck.

Hey Homer,

That answers my next question then, normally access to that is provided when you run the script, possibly try re-compiling it to reset the connection or if you have not create an app with the script, technically tho when you give it full disk access it should then run, if any part of the process is running make sure to full quit and relaunch it.

Regards

You should try wrapping each one of those Finder commands with a try statement. This way your script will continue running to the next command if there is an error. Try isolating if it’s just one of your commands or all of them are not working.

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/abook.sqlite" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing
end try

I tested your code with some of my own folders and I did not get any errors. I’m running the latest macOS

Mark & wch1zpink, thanks for the suggestions, I’ll try a few things over coffee tomorrow morning. I have a good number of Automator items that run perfectly, and changing my script to an Automator app would be a snap. But, once I’m faced with an issue like this, I’ll spend days to get it resolved. Retired, so I have a lot of time to fill :grinning:

Homer712. I’m not certain what is causing the error, but there are two possible issues, both of which arise from the use of POSIX file in a Finder tell statement. This is easily tested by deleting all instances of POSIX file and using HFS paths instead. For example:

tell application id "com.apple.Finder"
	duplicate file "Macintosh HD:Users:Robert:Working:Test File.txt" to folder "Macintosh HD:Users:Robert:Desktop:" with replacing
	duplicate file "Macintosh HD:Users:Robert:Working:Test File.txt" to folder "Macintosh HD:Users:Robert:Downloads:" with replacing
end tell

You may want to have a look at Nigel’s and Shane’s posts in the following thread. The situations are not directly analogous, but the posts point out issues that can arise when using POSIX file in a Finder tell statement.

Well, took more than one cup, but we have a working script. This works, why, I don’t have a clue, but it works. Added the “try” and “end try” as you suggested, and off it went.

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/abook.sqlite" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/history.sqlite" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/bookmarks.html" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/favicons.sqlite" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate file POSIX file ¬
		"/Users/margehomer/Library/Application Support/Firefox/Profiles/e4f5eay3.default-release/places.sqlite" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Firefox Bookmarks Sync" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
		"/Users/margehomer/Library/Application Support/ChronoSync/Tasks" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Backup Scripts/ChronoSync Tasks" with replacing
end try

try
	tell application id "com.apple.Finder" to duplicate folder POSIX file ¬
		"/Users/margehomer/Library/Application Support/XMenu/Custom" to the folder ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/XMenu Sync" with replacing
end try

delay 1

display notification "Completed Successfully!" with title "Pre Backup AppleScript"

The only remaining issue is that the notification at the very end of the script is not displaying. Any help there?

you don’t need the file keyword in front of POSIX file for the file to be copied, like so

try
	tell application id "com.apple.Finder" to duplicate POSIX file ¬
		"/Users/margehomer/Library/Thunderbird/Profiles/ya1l9e9n.default-esr/abook.sqlite" to the ¬
		POSIX file "/Users/margehomer/Documents/Mac Mini Specific/Address Book Sync" with replacing -- with or without trailing /
end try

After getting things running well, I decided to once again try my original script posted at the very top. For some unknown reason, possibly only known to Apple, it now works again, and is listed under System Settings > Privacy & Security > Files and Folders. Something must have been triggered somewhere, but I got things working again, thanks!

Mark, I’ve been thinking about your post ever since I’ve gotten things working again. And, I think the “re-compiling” is what did it. I first added the “try” and “end try” and it worked, then when I deleted the “try” and “end try”, it kept working. I’ll try to remember this for any future issues I may have with scripts. Thanks.

Hey Homer,

Sorry been busy all day, technically it could be but it could also be other items changing but I am glad you managed to get it working, sometimes not always the easiest of things to get going I know that’s a great feeling to have when it does work though.

Regards