Become a MacRumors Supporter for $25/year with no ads, private forums, and more!

Resolved How to hide ALL extensions on the whole HD? Need to make an automator flow.

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
There was a topic like that forever ago:

https://forums.macrumors.com/threads/362645/

The apple automator link mentioned therein is long dead, but I still have the file, from 2012. I run 10.10.
I double clicked on it, and automator says could not be loaded because can't be located, try reinstalling.

There is an app, very pricey at $15, to just do one thing that those horrid Windows machines do for free.

https://itunes.apple.com/us/app/file-folder-automator-action/id479445983?mt=12&ign-mpt=uo=8

I don't know the first thing about automator.
Could some brave soldier post instructions on how to use it (or anything else) to hide all extensions on my entire machine?

Many many thanks.
MC
 
Last edited:

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
Well, somebody was bound to say that. One born every minute.
Of course I've done that. Of course it does absolutely nothing. It's OSX. Designed to vacuum your wallet, not make your life easier.
 

w0lf

macrumors 65816
Feb 16, 2013
1,248
80
USA
This will take a long time (just 100 files as a test run took about 3 seconds)... Be prepared.

  1. Open terminal
  2. Install the Xcode command line tools with this line
    Code:
    xcode-select --install
  3. Run these commands
    Code:
    cd ~/Desktop
    touch hide_ex.command
    open -e hide_ex.command
  4. Paste this and save the file
    Code:
    #! /bin/bash
    
    #
    #	Hide extensions script
    #	Hides all extensions on all files for all user accounts
    #	Requires Xcode command line tools for SetFile
    #	By : w0lf
    #
    
    rr() {
    	for item in "$1"/*; do
    		if [[ -d "$item" ]]; then
    			echo "Entering directory: $item"
    			rr "$item"
    		elif [[ -w "$item" ]]; then
    			echo "Hiding extension for: $item"
    			SetFile -a E "$item"		
    		fi
    	done
    }
    
    rr /Users
    tput bel
  5. Back in terminal run
    Code:
    chmod 755 hide_ex.command
    ./hide_ex.command
  6. Every file affected will be printed out to terminal, you can minimize terminal and when it's finished you'll hear a ding sound and your minimized terminal window will get a notification badge.
  7. If you even want to run it again all you have to do is open the file you created which will be on your desktop.
 

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
@w0lf: you're a genius! worked like a charm. any way to also make it work on external drives? or should it? i only hooked the drive up a few minutes after it started running. it didn't hide them there.


@Dave: apologies. if you had spent 3 seconds trying it, you'd have seen it's useless, but you can't be blamed for expecting an insanely overpriced computer to do what it says.
 

w0lf

macrumors 65816
Feb 16, 2013
1,248
80
USA
@w0lf: you're a genius! worked like a charm. any way to also make it work on external drives? or should it? i only hooked the drive up a few minutes after it started running. it didn't hide them there.

Well you could either:

Add the line

Code:
rr /Volumes/"name of drive goes here"

Or

Change 'rr /Users' to

Code:
rr
 
Last edited:

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
thank you much again.
the volumes/name didn't work, so just did the root thing, and then watching terminal found that it did one of the external drives as:

//Volumes/HD/Volumes/HD/Volumes/name

and another as

//Volumes/HD/Volumes/name.

for internal it also seemed to do it two ways:

//Volumes/HD/Volumes/HD/Users

and

//Volumes/HD/

best,
mc
 

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
p.s.

You wouldn't have another magical code that would change case to Title Case (first letter of every word in the file/folder name to Capital), would you?

e.g., a file or folder named "MY STUFF" or "my stuff" would become "My Stuff".

I have many files and folders in all-lowercase and all-uppercase, and they draw attention to themselves, increasing search time in the process. It's just seconds, but it adds up over the years...

Thanks again,
mc
 

w0lf

macrumors 65816
Feb 16, 2013
1,248
80
USA
p.s.

You wouldn't have another magical code that would change case to Title Case (first letter of every word in the file/folder name to Capital), would you?

e.g., a file or folder named "MY STUFF" or "my stuff" would become "My Stuff".

I have many files and folders in all-lowercase and all-uppercase, and they draw attention to themselves, increasing search time in the process. It's just seconds, but it adds up over the years...

Thanks again,
mc

2 things.

1: My last post the second option should have been just

rr

without the slash. I'm not even sure why it would work with the slash.

2: Add this code below the line 'SetFile -a E "$item"' and above the fi

Code:
FileName=$(basename "$item")
FilePath=$(dirname "$item")
FileEdit=""
read -ra FileName <<<"$FileName"
for word in "${FileName[@]}"; do
	FileEdit="$FileEdit $(echo "$word" | tr '[A-Z]' '[a-z]' | awk '{ print toupper(substr($0, 1, 1)) substr($0, 2) }')"
done
FileEdit="${FileEdit# }"
mv "$item" "$FilePath"/"$FileEdit"
 

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
Worked beautifully!
But it only changed files, not folders. Any way to make it change them, too?

Also, could you please paste the whole code for just the case change, without extension hiding? Unless it makes no difference in how long it will run. I have a few TB of data, so even a small difference might be many many hours.
I daren't try to cut what I think the extension code is, lest I make the computer self-destruct, Mission-Impossible style.
Thank you muchly for your patience,
n
 

w0lf

macrumors 65816
Feb 16, 2013
1,248
80
USA
Worked beautifully!
But it only changed files, not folders. Any way to make it change them, too?

Also, could you please paste the whole code for just the case change, without extension hiding? Unless it makes no difference in how long it will run. I have a few TB of data, so even a small difference might be many many hours.
I daren't try to cut what I think the extension code is, lest I make the computer self-destruct, Mission-Impossible style.
Thank you muchly for your patience,
n

Code:
#! /bin/bash

# About		: 	Recursively Capitalize First Letter Of All Words For All Folders And Files
#			All other text will be made lower case
#			Only renames files and folders with Write permissions
#			Finder may need to be restarted for all changes to be visible
#			Should work on any OSX install
#			Terminal will beep and bounce in the dock (if not focused) when finished
#			Terminal screen will be cleared before script begins to output
#
# By		:	w0lf ( aguywithlonghair@gmail.com )
# Edited	:	2/24/15

rename_item() {
	FileName=$(basename "$item")
	FilePath=$(dirname "$item")
	FileEdit=""
	FileArray=""
	read -ra FileArray <<<"$FileName"
	for word in "${FileArray[@]}"; do
		FileEdit="$FileEdit $(echo "$word" | tr '[A-Z]' '[a-z]' | awk '{ print toupper(substr($0, 1, 1)) substr($0, 2) }')"
	done
	FileEdit="${FileEdit# }"
	if [[ "$item" != "$FilePath"/"$FileEdit" ]]; then
		echo "Renaming --- $item"
		echo "Old: $FileName"
		echo "New: $FileEdit"
		echo ""
		mv "$item" "$FilePath"/"$FileEdit"
		edit_count=$(( $edit_count + 1 ))
	fi
}

rr() {
	for item in "$1"/*; do
		if [[ -d "$item" ]]; then
			if [[ -w "$item" ]]; then
				rename_item "$item"
				rr "$FilePath"/"$FileEdit"
			else
				rr "$item"
			fi
		elif [[ -w "$item" ]]; then
			rename_item "$item"
		fi
		total_count=$(( $total_count + 1 ))
	done
}

clear && printf '\e[3J'
total_count=0
edit_count=0

# Basic usage examples:
# time rr 		# Entire system
# time rr /Users	# All Users
# time rr "$HOME"	# Current User only
time rr /Users

echo "Items scanned : $total_count"
echo "Items renamed : $edit_count"
echo ""
tput bel

# END

Code:
#! /bin/bash

# About		: 	Recursively hide all file extensions
#			Only attempts to edit files with Write permissions
#			Extensions not recognized by OSX will not be hidden
#			Finder may need to be restarted for all changes to be visible
#			Requires Xcode command line tools to be installed
#			If you do not have xcode command line tools installed you will be prompted to do so
#			Terminal will beep and bounce in the dock (if not focused) when finished
#			Terminal screen will be cleared before script begins to output
#
# By		:	w0lf ( aguywithlonghair@gmail.com )
# Edited	:	2/24/15

rr() {
	for item in "$1"/*; do
		if [[ -d "$item" ]]; then
			echo "Entering directory: $item"
			echo ""
			rr "$item"
		elif [[ -w "$item" ]]; then
			echo "Hiding extension for: $item"
			SetFile -a E "$item"
			edit_count=$(( $edit_count + 1 ))
		fi
		total_count=$(( $total_count + 1 ))
	done
}

clear && printf '\e[3J'
total_count=0
edit_count=0
xcode-select --install 2&> /dev/null

# Basic usage examples:
# time rr 		# Entire system
# time rr /Users	# All Users
# time rr "$HOME"	# Current User only
time rr /Users

echo "Items scanned : $total_count"
echo "Items changed : $edit_count"
echo ""
tput bel

# END
 

Mackist

macrumors member
Original poster
Dec 30, 2013
38
0
Amazing. You're a genius, sir. Many internets to you! Why can't you be the CEO of Crapple?
 

Command

macrumors regular
Jan 23, 2015
183
78
USA
Not everybody knows that, especially newcomers to Macs. You asked for help. It was given. Say "thank you".

It's managed globally here (How about Finder Preferences>Advanced>Untick Show All Filename Extensions?) and / or individually in the Info window of any Finder window, etc. Each view can be customized. Also, they're off by default. Once you start changing things, it can get out of hand but it's all there for you to play with to get what you want. Granted, once out of hand, the fix may not be 'just a tick' any longer.
 
Last edited:

MacUser85

macrumors newbie
Sep 27, 2015
2
0
How do you "run commands" in Terminal? Where is the "run" option or command? (Thanks, w0lf.)
 

Weaselboy

Moderator
Staff member
Jan 23, 2005
30,906
10,698
California
I know where it is. I had it open. But how do you run commands in it?
Simple commands you just type in and hit the return key and the command is run.

For example, type the command below in Terminal and hit return and your Mac will say hello to you.

Code:
say hello

For longer strings like w0lf lists up there you can save the command as a .sh file and execute the command(s) by launching the file. An article here explains in more detail.
 

Matt__James

macrumors regular
Mar 11, 2014
227
58
I just came across this thread and it seems to have worked spot on, thank you!

My question though, how long (roughly I know) should that script, or whatever it's referred to as, take? I started it at 8am this morning, and although all the files in my Documents folder now have the extension hidden, it's still running 3.5 hours later! Is this normal? I see w0lf said to be prepared for it take a while, but just checking.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.