erratic handling of "theFile" in embedded Applescript

Dear all,
I have an issue to get the Folder name of the currently processed file within an embedded AppleScript.
The purpose of the script is to create a new Apple Note with "theFile" as attachment, using the Mac Folder Name as a folder also in Notes.
I basically had the same script running for years for adding those files into Evernote, so I am really puzzled why I face issues now while testing the new script with Notes...
I also do not know, if it is an issue with Hazel (not handling "theFile" properly during my intensive testing?), or with Applescript itself.
The relevant line in the script is the following:
Here is the issue: sometimes ParentFolder is empty, sometimes not (meanwhile, the script directly checks "if length of ParentFolder" is >0.... and throws an error)
I am testing with a pdf file, being dropped into the same folder. After a test run, I delete it again from this folder and drop it again after changing the embedded script.
Using exactly the same source file, it may work (ParentFolder name is correctly set), or may not work (ParentFolder is empty) . It seems that killing hazel / or rebooting makes it work at first, bevor again showing the erratic behavior.
Using other files shows the same phenomenon.
any ideas ?
I just updated to the latest Hazel 5.1.4, running on a Mac mini with latest macOS 12.5.1
Thanks in advance !
I have an issue to get the Folder name of the currently processed file within an embedded AppleScript.
The purpose of the script is to create a new Apple Note with "theFile" as attachment, using the Mac Folder Name as a folder also in Notes.
I basically had the same script running for years for adding those files into Evernote, so I am really puzzled why I face issues now while testing the new script with Notes...
I also do not know, if it is an issue with Hazel (not handling "theFile" properly during my intensive testing?), or with Applescript itself.
The relevant line in the script is the following:
- Code: Select all
tell application "Finder"
set ParentFolder to (name of container of theFile) as string
end tell
Here is the issue: sometimes ParentFolder is empty, sometimes not (meanwhile, the script directly checks "if length of ParentFolder" is >0.... and throws an error)
I am testing with a pdf file, being dropped into the same folder. After a test run, I delete it again from this folder and drop it again after changing the embedded script.
Using exactly the same source file, it may work (ParentFolder name is correctly set), or may not work (ParentFolder is empty) . It seems that killing hazel / or rebooting makes it work at first, bevor again showing the erratic behavior.
Using other files shows the same phenomenon.
any ideas ?
I just updated to the latest Hazel 5.1.4, running on a Mac mini with latest macOS 12.5.1
Thanks in advance !