Album art as folder icon in Gnome
Sunday, 28. October 2007, 07:59:35
One of the rare advantages I find in Windows XP (strangely lost in Vista...) over Linux is the "Thumbnail View" option in Explorer, which replaces icons with thumbnail images. The Gnome desktop natively shows thumbnails of all images and films without the need to change view, as in XP, but the one advantage XP has over Gnome is that it also shows a thumbnail of the folder. With an image called folder.jpg in it, the folder thumbnail shows that image. This is not overly useful in most circumstances, but is excellent for viewing music albums.
It is possible in Gnome to change the icon of an individual folder to an image quite simply in properties, but with thousands of albums, that seemed like work...
NOTE: for Ubuntu 9.10 Karmic, see updated post here
However, I have found a very simple solution here. Ubuntu user fifo has created a very simple python script which you can download from the first link, above. The script basically automates the process of converting a folder icon to, by default, an image in that folder by the name of either folder.jpg or Folder.jpg.
To run the script, navigate to folder you have saved it to (in the terminal, e.g. "cd Desktop"), and type:
$ python custom_icon.py -R /folder/folder (replacing "folder" for the directory you want to convert)
The option -R means that not only the folder you enter, but all its subfolders will be converted.
To refresh Nautilus:
$ nautilus -q
An excellent and simple solution.
UPDATE:
The script as written assumes all the folder images are .jpg in lower case, but if some of your images are .Jpg or .JPG, then simply change the line:
default="[Ff]older.jpg",
to
default="[Ff]older.[Jj][Pp][Gg]",
This script can be downloaded here (all credit to fifo for writing this, I just added the default="[Ff]older.[Jj][Pp][Gg]", line...)
UPDATE 2:
This script does not work in Karmic Koala, but I have recently found a Cover Thumbnailer here that seems to work perfectly. Installation was via a .deb file, so could not have been simpler. I logged out and back in, and it worked. For music albums it adds a cd jewel case frame. For pictures and photographs it adds a photo album frame. I presume it uses the directory tree to ascertain which to use. All other folders with folder.jpg in them get a simple frame with a flip fold on the bottom left.
Below is a picture of the Music folder:
It is possible in Gnome to change the icon of an individual folder to an image quite simply in properties, but with thousands of albums, that seemed like work...
NOTE: for Ubuntu 9.10 Karmic, see updated post here
However, I have found a very simple solution here. Ubuntu user fifo has created a very simple python script which you can download from the first link, above. The script basically automates the process of converting a folder icon to, by default, an image in that folder by the name of either folder.jpg or Folder.jpg.
To run the script, navigate to folder you have saved it to (in the terminal, e.g. "cd Desktop"), and type:
$ python custom_icon.py -R /folder/folder (replacing "folder" for the directory you want to convert)
The option -R means that not only the folder you enter, but all its subfolders will be converted.
To refresh Nautilus:
$ nautilus -q
An excellent and simple solution.
UPDATE:
The script as written assumes all the folder images are .jpg in lower case, but if some of your images are .Jpg or .JPG, then simply change the line:
default="[Ff]older.jpg",
to
default="[Ff]older.[Jj][Pp][Gg]",
This script can be downloaded here (all credit to fifo for writing this, I just added the default="[Ff]older.[Jj][Pp][Gg]", line...)
UPDATE 2:
This script does not work in Karmic Koala, but I have recently found a Cover Thumbnailer here that seems to work perfectly. Installation was via a .deb file, so could not have been simpler. I logged out and back in, and it worked. For music albums it adds a cd jewel case frame. For pictures and photographs it adds a photo album frame. I presume it uses the directory tree to ascertain which to use. All other folders with folder.jpg in them get a simple frame with a flip fold on the bottom left.
Below is a picture of the Music folder:








ozmargot # 21. March 2008, 14:30
sjosul # 31. March 2008, 06:37
cirrusminora # 14. January 2009, 09:46
sjosul # 16. January 2009, 09:07
Anonymous # 1. July 2009, 16:02
Ah, excellent script. Been looking for just such a simple solution. Thank you.
sjosul # 2. July 2009, 04:10
Anonymous # 13. July 2009, 21:50
Oh that is such a nice piece of code.
Thanks a bunch.
Anonymous # 16. September 2009, 13:05
thanks for this :)
Anonymous # 5. October 2009, 14:17
thx man i love this trick!
Anonymous # 9. October 2009, 14:12
Thanks for this awesome tip. Searching for this for a while.
Anonymous # 12. October 2009, 21:21
Hi i've just found your script and doesn't work anymore in Ubuntu 9.10 Karmic. Aparently works fine, it makes the xml file but no changes are shown after restarting nautilus.
Do you know why?
granjerox [en] gmail [punto] com
sjosul # 13. October 2009, 22:33
Anonymous # 1. November 2009, 02:19
For all the guys who want to use this in karmic. The old script wont work any longer.
Try me adapted version:
#!/usr/bin/python
import sys
from optparse import OptionParser
import os
import fnmatch
from urllib import quote
def main():
parser = OptionParser(usage="usage: %prog [options] folder [folder2 ...]",
version="%prog 0.1")
parser.add_option("", "--names", dest="names",
default="[Ff]older.[Jj][Pp][Gg]",
help='specification to match image filenames [default: "%default"]')
parser.add_option("-R", "--recursive", dest="recursive", action="store_true", default=False,
help="set icons for folders recursively")
(options, folders) = parser.parse_args(sys.argv)
folders = folders[1:]
if not folders:
parser.error("no folders specified")
noquote = "()'*"
for folder in folders:
for root, dirs, files in os.walk(folder):
print root, "..."
subdirs = []
for d in dirs:
images = fnmatch.filter(os.listdir(os.path.join(root, d)), options.names)
if images:
path = os.path.join(root, d)
image = os.path.basename(images[0])
os.system('gvfs-set-attribute "%s" metadata::custom-icon "%s"' % (path, image))
else:
print "no image found for %s/%s" % (root, d)
if not options.recursive:
dirs[:] = []
print "done."
if __name__ == "__main__":
main()
sjosul # 1. November 2009, 08:48
sjosul # 3. November 2009, 01:09
From the site:
"Cover thumbnailer is a small Python script which displays music album covers in nautilus, preview of pictures which are in a folder and more.
The script fits in nautilus like any other thumbnailer of the GNOME thumbnail factory; so you don't have to run it manually to generate thumbnails.
Cover thumbnailer is free software under GNU GPL v3+ licence, you are free to modify and redistribute it under the terms of the license."
I just installed it in Karmic, logged out and back in, and it worked immediately for all folders with images. My music album folders (all with folder.jpg in them come up as cd jewel cases; picture and photographs come up as photo albums. other folders with folder.jpg in them come up as an image with a flip fold on the bottom left corner.
So far, a very nice addition to Nautilus.