I am using AppleScript on MacOS to create a backup copy of the bookmarks settings of the Safari browser as well as for other settings of other applications. I am experiencing issues with the command “duplicate” accessing the file “Bookmarks.plist” in the folder “/Users/<AccountName>/Library/Safari/
”.
To be specific, the following statement leads to the script error Finder got an error: The operation can’t be completed:
tell application "Finder" to duplicate file ((path to library folder from user domain as text) & "Safari:Bookmarks.plist")
Since the file Bookmarks.plist is available on every Mac in the respective directory, the statement and error above can be reproduced on any Mac easily.
Please note, that the statement itself is correct and not the source of the issue. As an example, a similar statement addressing another file in another directory works well:
tell application "Finder" to duplicate file ((path to library folder from user domain as text) & "Colors:NSColorPanelSwatches.plist")
You may reproduce this as well on any Mac.
To summarize: The problem only occurs with files in the the aforementioned directory /Users/<AccountName>/Library/Safari/
. If the file is stored anywhere else, it works fine.
Any ideas what might be the problem and how to circumvent. I tried already:
- Changed access rights
- Different files in the same directory: Did not work either
- Duplicated file to another folder: Did not work either → The issue seems to be caused by accessing the file not by copying.
Thank you for help!