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

Discussion in 'macOS' started by Mackist, Feb 18, 2015.

  1. Mackist, Feb 18, 2015
    Last edited: Feb 22, 2015

    Mackist macrumors member

    Joined:
    Dec 30, 2013
    #1
    There was a topic like that forever ago:

    http://forums.macrumors.com/showthread.php?t=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
     
  2. Dave Braine macrumors 68040

    Dave Braine

    Joined:
    Mar 19, 2008
    Location:
    Warrington, UK
    #2
    How about Finder Preferences>Advanced>Untick Show All Filename Extensions?
     
  3. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #3
    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.
     
  4. Dave Braine macrumors 68040

    Dave Braine

    Joined:
    Mar 19, 2008
    Location:
    Warrington, UK
    #4
    Not everybody knows that, especially newcomers to Macs. You asked for help. It was given. Say "thank you".
     
  5. w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #5
    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.
     
  6. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #6
    @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.
     
  7. w0lf, Feb 21, 2015
    Last edited: Feb 24, 2015

    w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #7
    Well you could either:

    Add the line

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

    Change 'rr /Users' to

    Code:
    rr
     
  8. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #8
    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
     
  9. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #9
    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
     
  10. w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #10
    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"
    
     
  11. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #11
    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
     
  12. w0lf macrumors 65816

    w0lf

    Joined:
    Feb 16, 2013
    Location:
    USA
    #12
    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
    
     
  13. Mackist thread starter macrumors member

    Joined:
    Dec 30, 2013
    #13
    Amazing. You're a genius, sir. Many internets to you! Why can't you be the CEO of Crapple?
     
  14. Command, Jul 4, 2015
    Last edited: Jul 4, 2015

    Command macrumors regular

    Command

    Joined:
    Jan 23, 2015
    Location:
    USA
    #14
    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.
     
  15. MacUser85 macrumors newbie

    Joined:
    Sep 27, 2015
    #15
    How do you "run commands" in Terminal? Where is the "run" option or command? (Thanks, w0lf.)
     
  16. Command macrumors regular

    Command

    Joined:
    Jan 23, 2015
    Location:
    USA
    #16
    Terminal is in the Utilities folder.
    Applications/Utilities on later versions.

    http://guides.macrumors.com/Terminal
     
  17. MacUser85 macrumors newbie

    Joined:
    Sep 27, 2015
    #17
    I know where it is. I had it open. But how do you run commands in it?
     
  18. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #18
    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.
     
  19. mattjackson macrumors member

    Joined:
    Mar 11, 2014
    #19
    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.
     
  20. mattjackson macrumors member

    Joined:
    Mar 11, 2014
    #20
    It's now been going for 12 hours!! Seriously is this right?!
     

Share This Page