Help with simple script

I got this script somewhere on the web and it keeps giving me an error. I am a complete newbie when it comes to scripting so i would like to know why and where this script breaks down.
Thank you in advance

property destFolder : {}
property jobFolder : {}
property job : {}
property actFolder : {}
property jobNumber : {}
property restcommands : {}
property text1 : {}
property text2 : {}
property text3 : {}
property text4 : {}
property text5 : {}
property text6 : {}
property text7 : {}
property text8 : {}
property text9 : {}

on run
	
	--
	--      Locate the destination folder
	--
	if (destFolder = {}) then
		set destFolder to ¬
			choose folder with prompt "Select destination folder:"
	end if
	
	--
	--      Name Job
	--
	if (job = {}) then
		set response to display dialog ¬
			"Name of Job? Please limit to 14 characters. (Example: ABC_Brochure): " default answer ""
		set job to text returned of response
	end if
	
	--
	--      Get Job Number
	--
	if (jobNumber = {}) then
		set response to display dialog ¬
			"What is the Job Number for this job? (Limit to 6 digits):" default answer ""
		set jobNumber to text returned of response
	end if
	
	
	--
	--      Name Job Folder
	--
	if (jobFolder = {}) then
		set jobFolder to jobNumber & "_" & job
	end if
	
	
	--
	--      Open Job Folder
	--
	if (actFolder = {}) then
		set actFolder to jobFolder
	end if
	
	
	--
	--      Create EPS Folder
	--
	if (text1 = {}) then
		set str to jobNumber
		set str to str & "_EPS_Files"
		set text1 to str
	end if
	
	--
	--      Create Fonts Folder
	--
	if (text2 = {}) then
		set str to jobNumber
		set str to str & "_Fonts"
		set text2 to str
	end if
	
	--
	--      Create Page Layout Folder
	--
	if (text3 = {}) then
		set str to jobNumber
		set str to str & "_Page_Layout"
		set text3 to str
	end if
	
	--
	--      Create Imposition Folder
	--
	if (text4 = {}) then
		set str to jobNumber
		set str to str & "_Imposition"
		set text4 to str
	end if
	
	--
	--      Create Support Folder
	--
	if (text5 = {}) then
		set str to jobNumber
		set str to str & "_Support"
		set text5 to str
	end if
	
	--
	--      Create FPO Files Folder
	--
	if (text6 = {}) then
		set str to jobNumber
		set str to str & "_FPOs"
		set text6 to str
	end if
	
	--
	--      Create Images Folder
	--
	if (text7 = {}) then
		set str to jobNumber
		set str to str & "_Images"
		set text7 to str
	end if
	
	--
	--      Create PDF Files Folder
	--
	if (text8 = {}) then
		set str to jobNumber
		set str to str & "_PDF_Files"
		set text8 to str
	end if
	
	--
	--      Create PDF Files Folder
	--
	if (text9 = {}) then
		set str to jobNumber
		set str to str & "_Customer_Files"
		set text9 to str
	end if
	
	
	
	try
		tell application "Finder"
			with timeout of 600 seconds
				close every window
				open destFolder
				make folder in destFolder with properties ¬
					{name:jobFolder}
				select folder actFolder of destFolder
				set new_file to (make file at selection)
				set the name of new_file to jobNumber & "_ReadMe"
				make folder in selection with properties ¬
					{name:text1}
				make folder in selection with properties ¬
					{name:text2}
				make folder in selection with properties ¬
					{name:text3}
				make folder in selection with properties ¬
					{name:text4}
				make folder in selection with properties ¬
					{name:text5}
				make folder in selection with properties ¬
					{name:text6}
				make folder in selection with properties ¬
					{name:text7}
				make folder in selection with properties ¬
					{name:text8}
				make folder in selection with properties ¬
					{name:text9}
				open folder actFolder of destFolder
				close destFolder
				set current view of window 1 to name
				set destFolder to {}
				set jobFolder to {}
				set actFolder to {}
			end timeout
		end tell
		
		
	on error -- error checking
		set str to "Zoinks!!! There has been an error! There already exists a folder with that name. Or the Project Name exceeds the
maximum number or characters allowed. Please try again and use another name."
		set destFolder to {}
		set jobFolder to {}
		set actFolder to {}
		set jobNumber to {}
		set text1 to {}
		set text2 to {}
		set text3 to {}
		set text4 to {}
		set text5 to {}
		set text6 to {}
		set text7 to {}
		set text8 to {}
		set text9 to {}
		error str
		set str to {}
		quit
	end try
	
	set destFolder to {}
	set jobFolder to {}
	set actFolder to {}
	set jobNumber to {}
	set job to {}
	set text1 to {}
	set text2 to {}
	set text3 to {}
	set text4 to {}
	set text5 to {}
	set text6 to {}
	set text7 to {}
	set text8 to {}
	set text9 to {}
	set str to {}
end run

Model: imac
AppleScript: 2.1.2 (82.1)
Browser: Safari 523.12.2
Operating System: Mac OS X (10.4)

It is kinder to folks who might want to try your script if you enclose it in AppleScript tags – I’ve done that to yours. With those tags, clicking on the link in the first line of the script (Open This Scriptlet in your Editor:) will download and display the script in your default script editor.

The script compiles for me (nothing the matter with it as it stands), so you’ll have to be a lot more descriptive of how it fails for you and what it is you expect it to do for you.

Sorry about my posting. Next time I will enclose the script correctly. I guess I need help in posting as well as scripting. Anyway i can compile the script, but when i run the script this is what happens
1 I am asked to chose the destination folder
2 I am asked to name the job
3 I am asked to supply a job number

Then I get an error message about ““Zoinks!!! There has been an error! There already exists a folder with that name. Or the Project Name exceeds the
maximum number or characters allowed. Please try again and use another name.””

It seems to error out at the line
error str

It will create the first folder in the folder that was picked and name it correctly. But does not create the other folders inside.

the error has to happen before the line you quoted: if an error ocurrs, the scripts jumps to the error message. at least that’s how every script / program I’ve ever seen works.

you gotta debug that script and find out where the error happens. for that purpose, you can use dialogs for example: it seems to be the easier way to do this it…

-- point 1
display dialog "the script works up until here: CHECKPOINT 1"

-- point 2
display dialog "the script works up until here: CHECKPOINT 2"

-- etc... 

Try to spead out the dialogs a little everywhere in your script, and you’ll find out where the script bugs.

Of course there’s a better way to do this:

  if (jobNumber = {}) then
       set response to display dialog ¬
           "What is the Job Number for this job? (Limit to 6 digits):" default answer ""
       set jobNumber to text returned of response
       display dialog jobNumber -- see if the text returned is what you entered for example
   end if

i’m no expert but this method usually is enough for me.

all the best

Some minor changes required.

property destFolder : {}
property jobFolder : {}
property job : {}
property actFolder : {}
property jobNumber : {}
property restcommands : {}
property text1 : {}
property text2 : {}
property text3 : {}
property text4 : {}
property text5 : {}
property text6 : {}
property text7 : {}
property text8 : {}
property text9 : {}

on run
	
	--   
	--      Locate the destination folder
	--
	if (destFolder = {}) then
		set destFolder to ¬
			choose folder with prompt "Select destination folder:"
	end if
	
	--
	--      Name Job
	--
	if (job = {}) then
		set response to display dialog ¬
			"Name of Job? Please limit to 14 characters. (Example: ABC_Brochure): " default answer ""
		set job to text returned of response
	end if
	
	--
	--      Get Job Number
	--
	if (jobNumber = {}) then
		set response to display dialog ¬
			"What is the Job Number for this job? (Limit to 6 digits):" default answer ""
		set jobNumber to text returned of response
	end if
	
	
	--
	--      Name Job Folder
	--
	if (jobFolder = {}) then
		set jobFolder to jobNumber & "_" & job
	end if
	
	
	--
	--      Open Job Folder
	--
	if (actFolder = {}) then
		set actFolder to jobFolder
	end if
	
	
	--
	--      Create EPS Folder
	--
	if (text1 = {}) then
		set str to jobNumber
		set str to str & "_EPS_Files"
		set text1 to str
	end if
	
	--
	--      Create Fonts Folder
	--
	if (text2 = {}) then
		set str to jobNumber
		set str to str & "_Fonts"
		set text2 to str
	end if
	
	--
	--      Create Page Layout Folder
	--
	if (text3 = {}) then
		set str to jobNumber
		set str to str & "_Page_Layout"
		set text3 to str
	end if
	
	--
	--      Create Imposition Folder
	--
	if (text4 = {}) then
		set str to jobNumber
		set str to str & "_Imposition"
		set text4 to str
	end if
	
	--
	--      Create Support Folder
	--
	if (text5 = {}) then
		set str to jobNumber
		set str to str & "_Support"
		set text5 to str
	end if
	
	--
	--      Create FPO Files Folder
	--
	if (text6 = {}) then
		set str to jobNumber
		set str to str & "_FPOs"
		set text6 to str
	end if
	
	--
	--      Create Images Folder
	--
	if (text7 = {}) then
		set str to jobNumber
		set str to str & "_Images"
		set text7 to str
	end if
	
	--
	--      Create PDF Files Folder
	--
	if (text8 = {}) then
		set str to jobNumber
		set str to str & "_PDF_Files"
		set text8 to str
	end if
	
	--
	--      Create PDF Files Folder
	--
	if (text9 = {}) then
		set str to jobNumber
		set str to str & "_Customer_Files"
		set text9 to str
	end if
	
	
	
	try
		tell application "Finder"
			with timeout of 600 seconds
				close every window
				open destFolder
				make new folder in destFolder with properties ¬
					{name:jobFolder}
				select folder actFolder of destFolder
				set new_file to make new file at (get selection)
				set the name of new_file to jobNumber & "_ReadMe"
				make new folder at (get selection) with properties ¬
					{name:text1}
				make new folder at (get selection) with properties ¬
					{name:text2}
				make new folder at (get selection) with properties ¬
					{name:text3}
				make new folder at (get selection) with properties ¬
					{name:text4}
				make new folder at (get selection) with properties ¬
					{name:text5}
				make new folder at (get selection) with properties ¬
					{name:text6}
				make new folder at (get selection) with properties ¬
					{name:text7}
				make new folder at (get selection) with properties ¬
					{name:text8}
				make new folder at (get selection) with properties ¬
					{name:text9}
-- The following depends on view settings, so commented out (*   *)
				(*open folder actFolder of destFolder
				close destFolder
				set current view of window 1 to name*)
				set destFolder to {}
				set jobFolder to {}
				set actFolder to {}
			end timeout
		end tell
		
		
	on error e -- error checking
		set str to "Zoinks!!! There has been an error! There already exists a folder with that name. Or the Project Name exceeds the
maximum number or characters allowed. Please try again and use another name."
		set destFolder to {}
		set jobFolder to {}
		set actFolder to {}
		set jobNumber to {}
		set text1 to {}
		set text2 to {}
		set text3 to {}
		set text4 to {}
		set text5 to {}
		set text6 to {}
		set text7 to {}
		set text8 to {}
		set text9 to {}
		error str
		set str to {}
		return
	end try
	
	set destFolder to {}
	set jobFolder to {}
	set actFolder to {}
	set jobNumber to {}
	set job to {}
	set text1 to {}
	set text2 to {}
	set text3 to {}
	set text4 to {}
	set text5 to {}
	set text6 to {}
	set text7 to {}
	set text8 to {}
	set text9 to {}
	set str to {}
end run

See, Adam, Bruce or Stefan are always here to help you when you got trouble with a script :wink:

Hi,

if you run the script only once, all the properties and reset lines (set whatever to {}) are not needed at all.
Here a shorter version of your script with some ad hoc error handling.
For the creation of the subfolders and the readme file the script uses shell commands


-- Locate the destination folder
set destFolder to choose folder with prompt "Select destination folder:"
--      Name Job
repeat
	set response to display dialog ¬
		"Name of Job? Please limit to 14 characters. (Example: ABC_Brochure): " default answer ""
	set job to text returned of response
	set countJob to count job
	if countJob < 15 and countJob > 0 then
		exit repeat
	else if countJob > 0 then
		display dialog "the Project Name exceeds the maximum characters allowed. 
Please try again and use another name." buttons {"Cancel ", "Try again"} default button 2 with icon 2 giving up after 2
	end if
end repeat
--      Get Job Number
repeat
	set response to display dialog ¬
		"What is the Job Number for this job? (Limit to 6 digits):" default answer ""
	set jobNumber to text returned of response
	set countJob to count jobNumber
	try
		jobNumber as integer
		if countJob < 7 and countJob > 0 then
			exit repeat
		else if countJob > 0 then
			display dialog "the Project number exceeds the maximum characters allowed . 
Please try again and enter ." buttons {"Cancel ", "Try again"} default button 2 with icon 2 giving up after 2
		end if
	on error
		display dialog "Please enter only numbers" buttons {"Cancel ", "Try again"} default button 2 with icon 2 giving up after 2
	end try
end repeat

--      Name Job Folder
set jobFolder to jobNumber & "_" & job
try
	set folderPath to ((destFolder as text) & jobFolder)
	folderPath as alias
	display dialog "the folder " & jobFolder & " already exists" buttons {"Cancel"} default button 1 with icon stop
on error number n
	if n = -128 then return
end try

do shell script "/bin/mkdir -p " & quoted form of POSIX path of folderPath & "/{" & jobNumber & "_EPS_Files," & ¬
	jobNumber & "_Fonts," & jobNumber & "_Page_Layout," & jobNumber & "_Imposition," & jobNumber & "_Support," & jobNumber & "_FPOs," & ¬
	jobNumber & "_Images," & jobNumber & "_PDF_Files," & jobNumber & "_Customer_Files}/; /usr/bin/touch " & quoted form of (POSIX path of folderPath & "/" & jobNumber & "_Readme.txt")

tell application "Finder"
	close every window
	open folder folderPath
end tell