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

Variable Folder Path AppleScript

Ive been working on a script for nearly a month now! Im still learning basics.


I have been trying to create a script that first reads all the folder names from a folder on the server.

It then takes those names and puts them in a drop down menu as list.

The folder name would be selected, then a dialog box would ask for a new folder name.

The script would then make the new folder in the folder that was selected previously.


Ive cracked the drop down menu part using CocoaDialog.


The problem I have is taking the selected folder and placing that at the end of the folder path.


Now im just getting into a mess with things and im going round and round in circles


So far I have:



set theFolder to alias "Server:folder"

tell application "System Events"


set l to {name of theFolder} & name of folders of theFolder

end tell


set args to ""

repeat with i from 1 to (count l)

set args to args & quoted form of item i of l

if i < (count l) then

set args to args & " "

end if

end repeat


(do shell script "/Applications/CocoaDialog.app/Contents/MacOS/CocoaDialog \\

standard-dropdown --title Title --text Text --items " & args)


set {button, answer} to paragraphs of result

if button is "1" then

return item (answer + 1) of l


set JobName to text returned of (display dialog "Please enter Job Name:" default answer "Job_Name")

set newfoldername to JobName

set thePath to theFolder & result as text

set newfolder to makenewfolderatthePathwith properties {name:newfoldername}

makenewfolderatnewfolderwith properties {name:"Admin"}

makenewfolderatnewfolderwith properties {name:"Images"}

makenewfolderatnewfolderwith properties {name:"Previous"}

makenewfolderatnewfolderwith properties {name:"Supplied"}

makenewfolderatnewfolderwith properties {name:"PDFs"}


end if

end




Any help would be amazing


Many thanks

Posted on Apr 3, 2014 8:32 AM

Reply
2 replies

Apr 3, 2014 2:32 PM in response to friskyfisky

You need to tell an application that can make folders to "make Folder".


In the simplest terms, this fails:


set the_folder to (choose folder)

makefolderatthe_folderwith properties {name:"New Folder"}


But this works:


set the_folder to (choose folder)

tell application "Finder" to makefolderatthe_folderwith properties {name:"New Folder"}


However, this would still error if a folder with that name already exists in that location and your script would need to allow for that.


Hope this helps.


Variable Folder Path AppleScript

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