Although I’ve disabled “Show file extensions” in the finder, I’ve noticed new behavior, recently: When i drag URLs from Safari to the desktop, the annoying “.webloc” is still visible. Not sure why this is happening, but I’d like to write a script to Get Info and hide that extension, then attach it to my desktop folder as a folder action.
I know nothing about AppleScript. Anyone care to help out, or point me in the right direction?
This is easy to do. Compile the following script in Script Editor and attach it to your folder:
on open of fileList
-- loop through the files
repeat with eachItem in fileList
tell application "Finder"
-- make sure we have a file, not a folder
if class of eachItem is file then
-- hide its extension
set extension hidden of eachItem to true
end if
end tell
end repeat
end open
Your script hides the extensions of all files in the folder to which it’s attached, but there are some files whose extensions I do want to be able tosee. Is it possible to single out only the files with the extension “.webloc”?
on open of fileList
-- loop through the files
repeat with eachItem in fileList
tell application "Finder"
-- make sure we have a file, not a folder
if class of eachItem is file then
-- check it's a .webloc
if name extension of eachFile is "webloc" then
-- hide its extension
set extension hidden of eachItem to true
end if
end if
end tell
end repeat
end open