Just want the folder name. Impossible?

Okay, I’m newer to applescript.

I’ve been reading and playing and can’t seem to find how to just get the folder name.

Everything I try returns something like:

/Users/Me/Here/My Folder

What I want is simply: My Folder

Can this be done?

Here’s the example code (provided by someone else). It asks for a directory.


	tell application "Finder"
		choose folder with prompt "Where to Save Directory/File.."
		set input to result
		set input to POSIX path of input
	end tell

Thanks

Try something like this:

choose folder
tell application "System Events" to set outputName to name of result
choose folder
set outputFolder to result
tell application "System Events" to set outputName to name of result

Wow thanks!

I spent hours looking for that.

I’m editing this msg, because I just fixed my automator issue.

Now I just need to find out how to run a script for every subfolder in one directory. :smiley:

you could also use:

tell application "Finder" to set outputName to name of result