Hide/Show File Extension Macro

I could use some help making a hide/show file extension macro. I want to select the file in the finder, and then go to the KM status menu and select the macro name, it runs the macro, and the file's extension appears or disappears depending on its current state. I got this far and got struck:

Using information gleaned from this post:

Here's one way to do it:

Show:Hide File Extension.kmmacros (4.1 KB)

1 Like

Here are alternative versions that will only show and only hide, as opposed to toggling.

Show File Extension.kmmacros (2.4 KB)

Hide File Extension.kmmacros (2.4 KB)

The AppleScript below will toggle file extension visibility. Simply use the Execute > Execute An AppleScript macro.

tell application "Finder"

	set _files to selection as alias list

	if _files is {} then return display alert "Nothing selected!" as warning giving up after 5

	repeat with f in _files

		set extension hidden of f to (not extension hidden of f)

	end repeat

	set selection to _files

end tell

Script source: https://github.com/wafflesnatcha/AppleScripts/blob/master/Applications/Finder/Toggle%20Hide%20extension.applescript

I greatly appreciate the help. I have both methods working. They do EXACTLY what I wanted.

Please check the "Solved" checkbox at the bottom of the post that solved/answered your question.

Both solutions worked. I checked the first one, but the other is just as good.

1 Like