Skip to content

Instantly share code, notes, and snippets.

@mehrshad-kh
Last active April 5, 2024 21:00
Show Gist options
  • Save mehrshad-kh/85f9b504e0e7f49c9c8279cf2c06c579 to your computer and use it in GitHub Desktop.
Save mehrshad-kh/85f9b504e0e7f49c9c8279cf2c06c579 to your computer and use it in GitHub Desktop.
An AppleScript that hides the extension of all images in a folder
# Interchange the following two for a Quick Action.
# on run {input, parameters}
on run
# Remove the following for a Quick Action.
set input to choose folder with prompt "Please select a document to pcoess:" with multiple selections allowed
tell application "Finder"
repeat with eachItem in input
# Recursively search through all subfolders.
if kind of eachItem is "Folder" then
set allFiles to (every file in entire contents of folder eachItem)
repeat with eachFile in allFiles
my hideExtension(eachFile)
end repeat
else
set eachFile to eachItem
my hideExtension(eachFile)
end if
end repeat
display dialog "Image extensions have been successfully hidden."
end tell
return
end run
on hideExtension(theFile)
tell application "Finder"
if extension hidden of theFile is false then
# Such as jpeg.
# set fileExtension to name extension of theFile
# Such as JPEG image.
set theKind to kind of theFile
if theKind ends with "image" then
set extension hidden of theFile to true
end if
end if
end tell
end hideExtension
@mehrshad-kh
Copy link
Author

This is an AppleScript that allows you to hide file extensions in Finder on macOS. It can be easily modified to suit your needs.

If you would like to use it as a Quick Action in Finder, simply create a Quick Action in Automator, and set it to run this AppleScript. You should only change two lines according to the comments. Afterwards, you can select files and folders in Finder as usual, right-click, and select your action from the Quick Actions menu.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment