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

Hide .webloc extension

When I drag a URL from the Safari address bar to the desktop, I get a .webloc extension. (I know, it's a common complaint, and I'm really surprised they didn't fix this in Leopard. What's the point of the "Hide Extensions" option if it doesn't work?)

Anyway, does anyone know how to get these to hide themselves? You can't just rename them because it screws them up and makes the bookmark unusable.

Thanks.

MacBook Pro 15", Mac OS X (10.4.7), 2 GB RAM

Posted on Nov 23, 2007 2:19 PM

Reply
8 replies

Nov 23, 2007 6:04 PM in response to Philpott

It is strange that the "hide extension" function doesn't work with those files.

It is also odd that Safari's .webloc files aren't created with a "type code", when those created by a third party browser like Shiira are... For example, if you have the "Developer" / "XCode" tools installed (it should be included on your Leopard DVD), a given .webloc file can be given a "type code" a command of this form:<pre>
/Developer/Tools/SetFile -t "ilht" /path/to/some.webloc</pre>

With the "type code" set, it should be possible to remove the extension and the system should still know what to do with the file. Perhaps an AppleScript droplet or Automator action could be created to automate the task...

Using "type" or "creator" codes to free you from file extension tyranny isn't something new, by the way. It is very old, and is a part of what gave Apple its "user friendly" reputation, which is why it is so strange that Apple was aggressively trying to move away from them in favour of extensions...

Nov 23, 2007 6:27 PM in response to Philpott

You can hide the extension using GetInfo, then in the the "Name and Extension" section check the "Hide extension" box--although why in the world it is defaulted to show extension I have no idea. Indeed, I have not found any rhyme nor reason to when things automatically hide extensions and when they don't. I have to explicitly check the Show Extension box when I save certain things, others (like the webloc) automatically have them. Some do, some don't, and I haven't a clue why.
Francine

User uploaded file
Francine
Schwieder

Nov 23, 2007 7:06 PM in response to biovizier

I unchecked the Show Extensions pref in Finder. But my Photoshop files all have their extensions, the aforementioned webloc files do too. TextEdit I add extensions, depending on whether it is a plain text file, rich text, or html, and when I do that the extensions are visible. Screenshots: some have no extension, some show .png, if I drag a jpeg out of web page, it has the jpg extension, and the photos that come out of Image Capture from my camera all come in with the jpeg extension. It is a mystery.

Webloc files are particularly strange: if you open one with TextEdit it is blank. If you drag one into Terminal it shows the actual URL, as it does if you drag it into Safari. If you look at the metadata you see a content type along these lines:

kMDItemContentType = "dyn.ah62d4rv4ge81s3pcrv10g"

If you remove the webloc extension it doesn't open in Safari, it becomes a blank sheet, but if you drop it in Terminal it still displays the URL, and still displays the URL in Safari, but metadat now shows a type of just "public data" and kind of Plain Text, although it is still blank when opened in TextEdit. HexEdit shows no data fork, just a resource fork.

I think I'm some sort of nut to have investigated this, but I got curious about webloc files and their strangeness awhile back.....
Francine

User uploaded file
Francine
Schwieder

Nov 23, 2007 7:36 PM in response to Francine Schwieder

Interesting that you should mention that - I must be a nut too then, since I did something similar a while back as well.

With Shiira .weblocs, they consist of XML in the data fork, and a 'url ' resource in the resource fork. In Tiger, they could function if they lost their extension because of the "type code" and resource fork, and could function without the metadata on the basis of the extension and the XML data so they were protected with redundancy. This wasn't a Shiira-only function since Safari could recognize both forms as well. So I always wondered why Safari didn't do the same and create these robust .webloc files.

But now, the metadata-free (XML plus extension) portion by itself doesn't seem to work anymore in Leopard, so does this mean they are moving toward a "resource fork" based file type? But if you have the essential resource fork, why not just set the "type" code as well? It all seems disorganized - lacking in direction, which I find worrisome...

Edit:
Oh, now how's this for irony? FireFox (an application ported to OS X) creates .webloc files that don't even have the .webloc extension. They have the XML, type code and 'url ' type code like Shiira's. So a port of a non-Mac browser creates files that are more Mac-like than the official Mac browser.

Jan 27, 2008 6:49 PM in response to Philpott

I managed to get this fixed for me using Applescript and Folder Actions. Create a new Applescript using Script Editor and paste the following into it:

---------------
on adding folder items to my_folder after receiving the_files
repeat with file_ in the_files
tell application "Finder"
tell item file_
set extension hidden to true
end tell
end tell
end repeat
end adding folder items to
---------------

Save it in HD/Library/Scripts/Folder Action Scripts as a Script.

Then attach it as a Folder Action to your Desktop folder.

More here:

http://discussions.apple.com/message.jspa?messageID=6452126#6452126

Hide .webloc extension

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