set UserName to (system attribute "USER") as text
try
set x to 5 / 0
on error
tell application "Finder"
make new folder at alias "Macintosh HD:Users:" & UserName & ":Desktop:" with properties {name:"Bob"}
end tell
end try
First said “Can’t get some object.”
Then said “Finder got an error: The operation could not be completed because there is already an item with that name.” Each next time.
Well I’m not sure what the 5 / 0 is hoping to accomplish, but you are missing “( )” to make this work like so
set UserName to (system attribute "USER") as text
try
set x to 5 / 0
on error
tell application "Finder"
make new folder at alias ("Macintosh HD:Users:" & UserName & ":Desktop:") with properties {name:"Bob"}
end tell
end try
But if all your trying to do is make a folder at the desktop of the current user you don’t have to poll system attributes
tell application "Finder"
make new folder at (path to desktop) with properties {name:"Bob"}
end tell
Thanks. It was intended to be part of a try statement so I included that just in case it was relevent.
And I need the username thing because I’m actually making it in user Library, and again included it in case it was relevent. I only did it to the desktop to simplify it.
Good call Stefan! After looking through my ‘path to’ commands I found it interesting that their is no path to the current users library folder just the system library. or am I missing something?