Job Folder with sub folders

Hi I modified a script I found here some time ago (ages)… have been using for some time. I used to always used to default to my WIP folder then I could select a folder from there, currently not doing that (new Mac)… so it defaults to the ‘documents folder’. Now question how can I have it always default to the ‘WIP’ folder and does this script look sound?.. could it be done any otherway… better?

thanks

-- Set common desktop path
display dialog "Please choose the Client Folder on the Server" buttons {"No", "Yes"} default button 2 with icon 2
set the user_choice to the button returned of the result
if the user_choice is "Yes" then
	set DeskTopFolder to (choose folder)
	
	-- User enters Job Number and Desciption
	set ClientCode to "What is the Client Code? (must be 3 letters, please use uppercase)"
	set JobNumber to "What is the Job Number? (must be 4 digits)"
	set JobDescription to "What is the Job Description?"
	set tempCode to display dialog ClientCode default answer ""
	set ClientCodeEntered to text returned of tempCode
	set tempNumber to display dialog JobNumber default answer ""
	set JobNumberEntered to text returned of tempNumber
	set tempDescription to display dialog JobDescription default answer ""
	set JobDescriptionEntered to text returned of tempDescription
	
	-- tell finder to create parent folder and sub folders
	tell application "Finder"
		set parentFolder to make new folder at DeskTopFolder with properties {name:ClientCodeEntered & JobNumberEntered & " " & JobDescriptionEntered}
		set buildFolder to make new folder at parentFolder with properties {name:"build folder"}
		make new folder at parentFolder with properties {name:"links folder"}
		make new folder at parentFolder with properties {name:"dispatch folder"}
		make new folder at parentFolder with properties {name:"eproof folder"}
		make new folder at parentFolder with properties {name:"supplied files"}
		make new folder at buildFolder with properties {name:"support folder"}
		make new folder at buildFolder with properties {name:"old folder"}
	end tell
end if

Model: MacPro
Browser: Safari 531.9
Operating System: Mac OS X (10.6)

Hi,

choose folder has a default location parameter (type alias)


.
set DeskTopFolder to choose folder default location alias "path:to:folder:"
.

Hi Stefan, thank you very much for this worked perfectly.
What do you think of the script overall?

I use it with a Acrobat pdf jobsheet system I have made, have another script that too asks if you want to repeat the process.

I should turn the pdf jobsheet into an actual application … doing that soon I hope.

Hi,

this is a version with a proper error handling, the letters will be converted to uppercase automatically.
To create the folders the shell command mkdir is used, which can create multiplie folders in one line


-- Set common desktop path
set {button returned:user_choice} to display dialog "Please choose the Client Folder on the Server" buttons {"No", "Yes"} default button 2 with icon 2
if the user_choice is "No" then return
set DeskTopFolder to POSIX path of (choose folder default location alias "path:to:folder")

-- User enters Job Number and Desciption
set ClientCode to getData("What is the Client Code? (must be 3 letters)", 2)
if ClientCode = false then return
set JobNumber to getData("What is the Job Number? (must be 4 digits)", 3)
if JobNumber = false then return
set JobDescription to getData("What is the Job Description?", 1)

-- create parent folder and sub folder
do shell script "/bin/mkdir -p " & quoted form of DeskTopFolder & "/" & ClientCode & JobNumber & "\\ " & JobDescription & "/{links\\ folder,dispatch\\ folder,eproof\\ folder,supplied\\ files,build\\ folder/{support\\ folder,old\\ folder}}/"

on getData(msg, mode)
	repeat
		set t to text returned of (display dialog msg default answer "" buttons {"OK"} default button 1)
		if mode = 1 then
			return t
		else if mode = 2 then
			if length of t = 3 then
				return do shell script "/bin/echo -n " & t & " | /usr/bin/tr a-z A-Z"
			else
				set b to button returned of (display dialog "Please enter 3 letters" buttons {"Quit", "Again"} default button 2)
				if b is "Quit" then return false
			end if
		else if mode = 3 then
			try
				if length of t ≠ 4 then error
				t as integer
				return t
			on error
				set b to button returned of (display dialog "Please enter 4 numbers" buttons {"Quit", "Again"} default button 2)
				if b is "Quit" then return false
			end try
		end if
	end repeat
end getData

Hi Stefan, sorry just got back… wow this is great thank you.

Hi Stefan, I have reverted back to the older script as this one only submits the first word of the description.
thanks.

Hi… again… I think it is something up with 10.6.2 anbd that last script just upgraded