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.

How to batch hide extensions using Automator or Finder Service?

HI, I saw there is a closed discussion on that How to batch hide extensions using Automa… - Apple Community; with a script suggested by VikingOSX; as it's an old discussion I understand I cannot reopen it.


I did exactly what suggested in that thread (create a quick, actions copied the scripts, clicked the hammer and saved the action) ; however (at least on OSX Catalina) the scripts works only when I select files, but doesn't work with folders nor recursively.


Can someone advise ?


iMac 27″, macOS 10.15

Posted on Apr 17, 2022 4:13 AM

Reply

Similar questions

11 replies

Apr 17, 2022 6:17 AM in response to VikingOSX

Thank you Viking OSX for your answer, however this does not work in my case.. below you can see the action (though in my language) ; as said in I right click a folder and select the quick action, nothing happens; but if I select just files it works...

Dont know what to think... (I though it might be a question of rights on the folder, but in this case I should not be able to rename, or delete the folder, so I don't think its a question of owner rights..)

I don't want change of course the extension of the folder, but of the files inside..



Apr 17, 2022 5:37 AM in response to mibigo

The AppleScript that I provided in that post still tests correctly (2022-04-17) on Catalina 10.15.7 when used as a Quick Action. It does recursively hide the file extensions of all files in a selected folder or hides the extensions of selected files in the Finder. It does nothing to a folder that you may have named with an extension though, which would not be sensible on a UNIX system.

Apr 17, 2022 11:02 AM in response to VikingOSX

I can't Believe that! It worked!... I only replaced the first occurence of "Folder" with "Cartella" (the second occurence I'm not allowed, I get an error message whereas "" are expected, but even if I put "Cartella" I still get the error) and it worked...!

I'm quite surprised though.. I don't know anything of programming language, however I always noticed that in Terminale for examples any names of folder is always translated by the terminal in English; so that If I drag and drop the folder "Immagini" for examples (the name that appears in the Finder, into the terminal window, it translate it into "Pictures". that's why when I do a script for example that call Rsync I have to specify the path in English. So I'have always thought that for programming anything I should have used the EN names..

By the way that was the case some OS ago... I had copied a similar script to yours to do the same some years ago (I don't remember though what version of the OSX was) and it worked the same but it used "Folder".. I would never ever thought that could be the problem!


Thank you very much indeed and Happy Easter! that was really an Easter egg.. :-))


Best


on run {input, parameters}
tell application "Finder"
		repeat with anItem in input
			if kind of anItem is "Cartella" 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





Apr 17, 2022 12:23 PM in response to VikingOSX

the Kind is indeed "Cartella". Which complicates very much adapting scripts found on the internet which are all in English to localized versions of OSX ; one should know what are the elements of apple scripts or shell scripts which should be or not "translated" into local language. Meaning you have to make a course for programming in apple script; while the average user like me limits to find some scripts for doing basic things and tries to use it in its environment; so far I managed to do some basic things but if variables like language enters into play, then it becomes hard to devine what has to be "translated and what not.

Apr 17, 2022 4:04 PM in response to mibigo

AppleScript is an old language that does not know about localization or translation. It needs help and I am betting that Spotlight has the answer:


use scripting additions

set f to choose folder

tell application "Finder" to set fname to name of f
set folderName to (do shell script "mdls -name kMDItemKind " & POSIX path of f & " | awk '{gsub(/\"/, \"\", $3);print $3}'")
# show the localized name of the folder
tell application "Finder"
	if kind of f is folderName then
		display dialog folderName
	end if
end tell
return


Apr 18, 2022 1:45 PM in response to mibigo

In the case of the Finder's kind of usage, it queries Spotlight for the locale name for "Folder.' Any future AppleScripts that you encounter that make this test in the Finder, you should precede them with that code that I posted on 2022-04-17 above. That way, you have the localized name string "Cartella" that you can use as folderName is above.


The first paragraph may not solve all required translations for you.

How to batch hide extensions using Automator or Finder Service?

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