You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Trying to implement a quick action to hide file extensions

Found a post to do this but can't get it working. Has anyone got a quick action that I can just plug in?

Posted on Sep 6, 2022 5:12 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 7, 2022 5:09 AM

Why don't you pass in the selected files from the Finder into the Quick Action, which is using a Run AppleScript action. In a loop, you test if the items extension is hidden or not and set it to the opposite, or do nothing, depending on your goal. The following Run AppleScript will hide the extensions of all files in a selected folder, or any selected file in the Finder:


use scripting additions

on run {input, parameters}
	
	-- recursively hide file extensions in a selected folder, or on 
	-- individually selected files in the Finder
	tell application "Finder"
		repeat with anItem in input
			if kind of anItem is "Folder" then
				set theFiles to (every file in entire contents of folder anItem)
				repeat with afile in theFiles
					set extension hidden of afile to true
				end repeat
			else
				set extension hidden of anItem to true
			end if
		end repeat
	end tell
	return
	
end run



4 replies
Question marked as Top-ranking reply

Sep 7, 2022 5:09 AM in response to guyHickey

Why don't you pass in the selected files from the Finder into the Quick Action, which is using a Run AppleScript action. In a loop, you test if the items extension is hidden or not and set it to the opposite, or do nothing, depending on your goal. The following Run AppleScript will hide the extensions of all files in a selected folder, or any selected file in the Finder:


use scripting additions

on run {input, parameters}
	
	-- recursively hide file extensions in a selected folder, or on 
	-- individually selected files in the Finder
	tell application "Finder"
		repeat with anItem in input
			if kind of anItem is "Folder" then
				set theFiles to (every file in entire contents of folder anItem)
				repeat with afile in theFiles
					set extension hidden of afile to true
				end repeat
			else
				set extension hidden of anItem to true
			end if
		end repeat
	end tell
	return
	
end run



Sep 6, 2022 10:07 PM in response to guyHickey

You need to perform two steps. Enforce the hide and then restart the Finder so it reads the change to the preference. Something like this can work:


This is using a defaults command to toggle the view of extensions to false (don't show) and an AppleScript to quit the Finder and then launch it. Save this as a Quick Action and it will appear in your Services menu (Enable Finder Suffixes).



By any chance are your devices managed by an MDM? If so, just issue this as a configuration profile. Please note, if the users figured out how to turn the on and you want it off, then the solution above can be overridden by the end users. It is not enforcing the setting, it is only toggling it when run. If you want to enforce the setting, use a profile in MDM.


Hope this helps. Quick and simple. You did not share the original post so I am making assumptions this is what you want done.


Reid

Trying to implement a quick action to hide file extensions

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.