I want the "Folder" property of a folder not it's class.

I'm trying to set a boolean value to myVariable using the "Folder" property, but the Applescript editor keeps interpreting it as a class.

Here is a shorted code. this is part of a bigger code to identify files dropped into a folder and create a new folder which it renames based on the date of the file that is dropped into the folder. Unfortunately, it keeps making folders every time it makes a new folder. Resalting in continuous loop of folders being created and renamed to "2025".

The plan is to us an IF condition to prevent the creation of folders when a folder/s are dropped into my folder with my Folder Action.

property directory : "Catalina:Users:Username:Desktop:Folder:File.pdf

tell application "Finder"
 set pathname to POSIX path of directory
 set item_info to the info for directory
 set myVariable to Folder of item_info
 return myVariable
end tell

I noticed the following when I compile the script

  • The color of the "Folder" is blue. I believe this means it's a class. Normally when I call a property, the color turns pink. it does it correctly when I use "set the file_name to the "name" of this_file". I also tried declaring the "Folder" property in brackets "Folder". did not help

I noticed the following when I run the script:

  • It returns ---error number -10004 "A privilege violation occurred. When it runs the "info for" command.

I gave the Script Editor Full File access, Full Accessibility access and the FolderActionsDispatcher has full Finder access.

Can anyone point me in the right direction!

  1. What is the cause of the privilege violation or how would I find what the cause is?
  2. How do I force the Script Editor to get the "Folder" property of a folder?

Inside a Finder tell statement, the term folder is indeed a class. You would need to use the statement outside the tell statement, or use something from the Finder itself such as the kind property, for example:

	set myVariable to (kind of (directory as alias) is "Folder")

Note that kind can differ from info for, since bundles/packages such as applications are technically also folders.

The privilege violation is from using the info for command (a long deprecated StandardAdditions command) in a Finder tell statement. There are a few that don't trigger the warning, such as display dialog, but common practice is to only use statements inside an application tell statement that specifically target that application. The terms my or of me can be used for statements that target something else (handlers, etc), but this case is problematic in that the result from info for actually uses scripting terms for the record keys.

I want the "Folder" property of a folder not it's class.
 
 
Q