Hmm… Aha…

stuff might interest somebody

Add ‘Where from:’ to Firefox downloads (Mac OS X)

Posted by f3lix on January 9, 2009

If you used Safari before you switched to Firefox, you might miss Safari’s feature that annotates each download with the URL it was downloaded from.  So if you find file in Download folder and wonder where it came from, you use Finder (“File > Get Info” or CMD+I) to show it’s source URL. Or if you like the shell, you can use the mdls command-line tool to get the info:

#> /usr/bin/mdls -name kMDItemWhereFroms a_downloaded_file.pdf
kMDItemWhereFroms = ""

Manually setting the “Where From:” URL

Today I asked myself if there was also a way to write this data. I did a little research on the web and found out the “Where From”-URL is actually saved in as an extended attribute. Extended attributes can be manipulated with the xattr command. So you can specify the URL for a file by running

/usr/bin/xattr -w '' <filename>

Make Firefox to set kMDItemWhereFroms

Now, what we really want is to have Firefox set the kMDItemWhereFroms property for us automatically. As I’m not familiar with programming Firefox extensions. I decided to modify an existing one: Download Statusbar I only had to write the following function, add it to the Downbar.prototype in downbar.js and call it from the db_finishDownload function.

    db_SetMetadata: function(aDownload) {
        var cmd = '/usr/bin/xattr'
        var execFile = Components.classes[";1"].createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes[";1"].createInstance(Components.interfaces.nsIProcess);
        // Arguments must be separated into an array
        var args = ['-w', '', "'"+aDownload.source.spec+"'", aDownload.targetFile.path ];
        if (execFile.exists()) {
  , args, args.length);

You can also download a patch at

Edit: for download bar the patch is a tiny bit different. see


7 Responses to “Add ‘Where from:’ to Firefox downloads (Mac OS X)”

  1. moshisumo said

    thanx f3lix,
    long time since i’m looking for it
    i will relay it
    great stuff

  2. Victor Volle said


    have you asked the developer of Download Statusbar to add this patch to the normal distribution?


    • f3lix said


      No, I didn’t contact the developer, because I thought what I did was a nasty hack and adding it to the normal distribution never crossed my mind.

      So, what I did was to create a blog and put it there… and then forgot that I had this blog 🙂 until I needed my patch and I couldn’t find it on my computer …

      Felix R.

  3. dada said


    does not works with the last version of download statusbar

    any help


  4. ernstkm said

    (At least in recent versions of OS X, e.g., Lion), the WhereFroms metadata appears to be an array of strings. So the instructions here appear to work in that the “Where from:” shows up in Finder’s “Get Info” dialog box, but may cause unexpected behavior (or crashes) in other applications that try to read out the metadata (namely, Hazel).

    The solution I came up with is to wrap the appropriate array structure around the “aDownload.source.spec” when building up the ‘args’ array as shown above. Here’s what that looks like (and hopefully this makes it through the WordPress comment editor):

    // Arguments must be separated into an array
    var args = ['-w', '',
      '<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" ""><plist version="1.0"><array><string>'
      + aDownload.source.spec + '</string></array></plist>',
      aDownload.targetFile.path ];

    Here’s a pastebin version of that.

  5. […] following works too, even though is has different results when running the above commands […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: