How to hide all file extensions in subdirectories of a given folder?

by lejonet   Last Updated January 14, 2018 01:12 AM

I know that I can open the file information dialogue (Get Info) for several files at once using ⌘⌥I and hide/unhide file extensions. How do I accomplish this for all files in a directory tree (including files in subfolders)?



Answers 3


Ok, I found a solution using Hazel:

I created a rule based on their posting How to get Hazel to go into subfolders:

If (…) Kind is Folder

Do the following (…) run rules on folder contents

The next rule selects a certain set of files, e.g.

If (…) Kind is pdf

Do (…) Run AppleScript embedded script

The script is

tell application "Finder"
    set extension hidden of theFile to true
end tell

I defined more conditions more different file types, so it doesn’t work on all files as requested. With a limited number of different files this should be no problem.

lejonet
lejonet
December 16, 2013 15:56 PM

You can easily do this in Terminal with the SetFile command:

To hide file extensions in a directory and all sub-directories:

cd <path to directory>

find . -name "*.*" -exec SetFile -a -E '{}' \; | echo "hiding extensions"

(can change the second * to a particular extension type if you choose)

To show file extensions in a directory and all sub-directories:

cd <path to directory>

find . -name "*.*" -exec SetFile -a -e '{}' \; | echo "showing extensions"
l'L'l
l'L'l
December 16, 2013 15:58 PM

This was most helpful. Thank you!

Vukodlak75
Vukodlak75
January 14, 2018 01:01 AM

Related Questions


What does mac replace .img with .ndif extension?

Updated March 19, 2017 15:12 PM

How can I set program associations in mac?

Updated July 07, 2017 13:12 PM


TextEdit keeps changing file extensions when I save

Updated April 05, 2015 16:05 PM

Open arbitary file from Finder in TextMate

Updated April 17, 2015 20:05 PM