Variable not defined (AppleScript)
For some reason the name of thePath
comes up as not defined by my Automator workflow.
on run {input, parameters}
tell application "Finder"
set thePath to the (first item of the input)
set namedFolder to ((the name of thePath) as text)
set namedFolder to ((text 1 thru 13) of namedFolder)
end tell
return namedFolder
end run
Solution 1:
namedFolder
only exists in the scope of your tell
block. Define it first thing so that it will persist after you’re done with Finder.
set namedFolder to ""
tell application "Finder"
...
end tell
return namedFolder
Alternatively, you could just put the return
statement inside the tell
block.