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

Solution 1:

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"

Solution 2:

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 file types this should be no problem.