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.

AppleScript to hide file extension of selected Finder file(s)

Hello, I am trying to write an AppleScript that would hide the file extension of one or more files selected in the Finder.


I tried a number of approaches, none worked for me. (I also tried to write a script that would hide the extension of all files is a folder, also without success.)


For example, why would this not work:


tell application "Finder"

set fileList to every file of the selection

repeat with currentFile in fileList

set extension hidden of currentFile to true

end repeat

end tell


Would appreciate any help and guidance.


Thank you.

MacBook Pro

Posted on Oct 11, 2019 3:11 AM

Reply
Question marked as Top-ranking reply

Posted on Oct 11, 2019 7:39 AM

You will find that this will work:


tell application "Finder"
    if selection is {} then return
	set selList to selection
	repeat with anItem in selList
		set extension hidden of anItem to true
	end repeat
end tell
return


And using the Automator Quick Action that I provided in this earlier post, you can select multiple files in the Finder, right-click on one of them, and use the Quick Action menu item to invoke a Quick Action to hide all file extensions of the selected files. If you select a folder instead, it will recursively hide all file extensions in the entire folder contents. I created a duplicate Quick Action to restore the extensions of selected files (or folder contents).

Similar questions

1 reply
Question marked as Top-ranking reply

Oct 11, 2019 7:39 AM in response to Hilal Malawi

You will find that this will work:


tell application "Finder"
    if selection is {} then return
	set selList to selection
	repeat with anItem in selList
		set extension hidden of anItem to true
	end repeat
end tell
return


And using the Automator Quick Action that I provided in this earlier post, you can select multiple files in the Finder, right-click on one of them, and use the Quick Action menu item to invoke a Quick Action to hide all file extensions of the selected files. If you select a folder instead, it will recursively hide all file extensions in the entire folder contents. I created a duplicate Quick Action to restore the extensions of selected files (or folder contents).

AppleScript to hide file extension of selected Finder file(s)

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