I know this should have taken me all of 30 seconds to write; obviously I am missing some key concept here…
All I want to do is create a new folder in a designated location; the requirements are simply that a name has to be supplied and that name can not already be used.
Here’s where am I right now:
--set names for dummy text files
set textAnimation to "AFX, Motion, 3D, Etc"
set textDocs to "Any text based documents associated with the project"
set textDVDbuild to "DVD Studio Pro Project Files, and Builds"
set textDVDrip to "Source Ftg from DVD"
set textFinalExport to "Stand Alone Quicktime for Mastering"
set textSourceMovs to "Jumpbacks, Stock Ftg, Etc Go Here"
global theAssets
global nameProject
--eventually make this a global variable
set theAssets to choose folder with prompt "Please select your Assets folder"
repeat
try
set nameProject to name_Project()
tell application "Finder"
if (exists folder nameProject of theAssets) is false then
exit repeat
end if
end tell
end try
end repeat
tell application "Finder"
make new folder at theAssets with properties {name:nameProject}
end tell
--subroutine to set name for new project; blank entry is not an option
on name_Project()
repeat
display dialog "Enter a name for the new project:" default answer ""
try
set tempName to the text returned of result
if tempName is not "" then
exit repeat
else
display dialog "Please enter a name for your project." buttons {"OK"}
end if
end try
end repeat
return tempName
end name_Project
This works, but there is no graceful way to exit. If the name is taken, it goes back to request a name, as I would like, but if the user decides to bail, pushing the “cancel” button simply goes back to request a name, because the script sees that as an empty name. I realize this is exactly what I have told it to do, but I’m just lost…
Thanks in advance.