Create a folder in user folder

I am confused why this isn’t creating a new folder in the specified path?
I am getting an error: Can’t make “Remove_Character_Files” into type integer.
Can anybody help describe this error to somebody who doesn’t get scripting very well?

Thanks,
jeff

property mainFolder3 : "Remove_Character_Files" -- Change this as needed


tell application "Finder"
if not (exists folder mainFolder3 of ((path to current user folder as Unicode text) & "Library:Application Support:")) then
set destFolder2 to make folder at ((path to current user folder as Unicode text) & "Documents:Library:Application Support:") with properties {name:mainFolder3}
	end if
end tell

Hi Jeff,

you’re checking a folder of a string path (folder “Remove_Character_Files” of “Mac HD.Application Support”)
but you want to check a folder of a folder


"property mainFolder3 : "Remove_Character_Files" -- Change this as needed

tell application "Finder"
	if not (exists folder mainFolder3 of folder ((path to current user folder as Unicode text) & "Library:Application Support:")) then
		set destFolder2 to make folder at folder ((path to current user folder as Unicode text) & "Documents:Library:Application Support:") with properties {name:mainFolder3}
	end if
end tell

or, shorter, in this case the script checks a folder of an alias


property mainFolder3 : "Remove_Character_Files" -- Change this as needed

tell application "Finder"
	if not (exists folder mainFolder3 of (path to application support folder from user domain)) then
		set destFolder2 to make folder at (path to application support folder from user domain) with properties {name:mainFolder3}
	end if
end tell

Stefan,
Thank you very much for the explanation, and it now makes sense. FWIW, I was trying to replicate a script that pathed to the desktop. (see below) But I guess the desktop has special rules that allow it not to be defined as a folder, but rather simply “desktop”? Is this wrong logic on my part?

if not (exists folder mainFolder of desktop) then -- Check to see if the folder exists
		set destFolder to make folder at desktop with properties {name:mainFolder} -- If not, make it.
	end if

Oh and btw, I shouldn’t have included “Documents” in the path in my original post. That was an oversight that I knew about but forgot about before I posted :frowning:

Thanks again,
Jeff

As desktop is the top level folder of the Finder, you actually don’t need to mention it


property mainFolder : "Remove_Character_Files" -- Change this as needed

tell application "Finder"
	if not (exists folder mainFolder) then -- Check to see if the folder exists
		set destFolder to make folder with properties {name:mainFolder} -- If not, make it.
	end if
end tell

You can refer to the desktop of the current user in these ways:
outside Finder or System Events tell block

path to desktop --> alias "Mac HD:Users:myUser:Desktop:
-- or
path to desktop folder --> alias "Mac HD:Users:myUser:Desktop:

inside a Finder tell block

tell application "Finder" to desktop --> object (file specifier) desktop

inside a System Events tell block

tell application "System Events" to desktop folder --> object (file specifier) desktop

Unlike the Finder, the top level folder of System Events is the root directory to the startup disk

I’ll be bookmarking this thread. Many thanks!!!

-Jeff