How can I copy the name of the current folder to the clipboard?

I'm trying to create a macro that will copy the name of the folder that I currently have open in the finder to the clipboard. I'm NOT trying to copy the finder path to the clipboard. I want to copy the name I have given to the folder to the clipboard. I want to do this because when I start a new project I will name the folder then copy the name to the clipboard so I can paste it on several other files. I frequently forget to copy the name to the clipboard when I am naming the file and by the time I remember I will have to go up a level in the finder to copy the name.

Does anyone know how to do achieve in Keyboard Maestro?

very easy
change temporary main to the system clipboard or just use command C

1 Like

I see what you've done there, but my reason for posting this is because I forget to copy the folder to the clipboard when I am naming it, I have to click the back arrow, press return & copy to clipboard.
Can applescript get the name of the folder in the front window? It can get the path, but can it get the name given to the folder that finder is currently in?

This is a solution to part of my problem, copies the selected folder to the clipboard and I will start using this.

TLDR - I'm trying to copy "Downloads" to the clipboard if I currently have the downloads folder open in a window. Maybe what I'm trying to do is overly complex for the solution it is solving, for me it is a daily frustration having to go back a level and copy to the clipboard.

I'm still learning scripting & automation and I hope my query isn't unreasonable! Thanks for the help @RazMastero !

Try using a token to save the front window name to a variable:

Or directly to the system clipboard:


You might also be interested in this macro I use a lot for either copying the folder name or renaming it in place.

Rename Folder.kmmacros (8.1 KB)


This looks interesting! Thanks

1 Like