Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Creating folder names with variables in applescript?

im trying to make folders and name them with structured names but im getting an error and im not sure what im doing wrong.



the error i get is:

Finder got an error: Can’t make "/Users/USERNAME/Desktop/Fake Server/Project Name" into type item.



----------------------these variables are just used for my example, the actual script asks for input and makes that into the variables -------------------

set the_folder to "Macintosh HD:Users:USERNAME:Desktop:Fake Server"

set theChosenOne to "Selected"

set Code to "ABCD"

set Number1 to "12345"


set projLocation to (POSIX path of the_folder & "/" & theChosenOne)

set folderTags to Code & " " & Number1


tell application "Finder"

makenewfolderatprojLocationwith properties {name:folderTags & " artfile"}

end tell

Applescript-OTHER, Mac OS X (10.7.4)

Posted on May 30, 2012 6:12 PM

Reply
6 replies

May 30, 2012 6:19 PM in response to b3nnb

Use the following:


set the_folder to "Macintosh HD:Users:USERNAME:Desktop:Fake Server"

set theChosenOne to "Selected"

set Code to "ABCD"

set Number1 to "12345"


set projLocation to (the_folder & ":" & theChosenOne)

set folderTags to Code & " " & Number1


tell application "Finder"

make new folder at projLocation with properties {name:folderTags & " artfile"}

end tell


In general, you only need to convert something to a POSIX path when you'll be using it inside a do shell script command.


(66841)

May 31, 2012 6:03 AM in response to b3nnb

The following should work:


set the_folder to "/Users/USERNAME/Desktop/Fake Server"

set theChosenOne to "Selected"

set Code to "ABCD"

set Number1 to "12345"


set projLocation to POSIX file (the_folder & "/" & theChosenOne)

set folderTags to Code & " " & Number1


tell application "Finder"

makenewfolderatprojLocationwith properties {name:folderTags & " artfile"}

end tell


Message was edited by: Pierre L.

Creating folder names with variables in applescript?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.