My current script uses the following as part of a larger workflow:
display dialog "ENTER JOB CODE:" default answer "JobCode"
set projCode to text returned of result
set projectFolder to choose folder with prompt "SELECT PROJECT FOLDER for " & projCode
The user inputs projCode in the following format: ABCDEXY123. It’s used to rename files using the same code with suffixes.
Is it possible to get just the “XY123” part of that code to prepend projectFolder’s name as the final step in the overall script without having to add another step to input just that part projCode? Any insights would be appreciated. Thanks!
haolesurferdude, neither of those is a good idea. They’re inefficient – you’re making lists and then concatenating them – and they’re error-prone because the result will depend on the value of text item delimiters when you run it. Better to use this:
Thanks for the quick response! Unfortunately I got an error stating that it couldn’t get the name of the alias for the folder (followed by the full path name).
You have to tell either System Events or the Finder to get and set the folder’s name:
display dialog "ENTER JOB CODE:" default answer "JobCode"
set projCode to text returned of result
set projectFolder to choose folder with prompt "SELECT PROJECT FOLDER for " & projCode
set prepend to text -5 thru -1 of projCode
tell application "System Events" to set name of projectFolder to (prepend & " - " & (get name of projectFolder))