Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to change the icons of multiple files from terminal.
Not launcher icons, but the default icons for filetypes, based on the file endings.
How to acheive this task?

share|improve this question
    
Do you mean like you can through right click -> Properties in the file manager? –  dv3500ea May 2 '11 at 9:25
    
Is that launcher icons, or the default icons for filetypes, based on the file endings? –  Erik Kronberg May 2 '11 at 9:26
    
Yes i want to change the icons of multiple files into one icon. –  karthick87 May 2 '11 at 9:27
    
Not launcher icons, default icons for file types. –  karthick87 May 2 '11 at 9:27

1 Answer 1

up vote 8 down vote accepted
+50

"emblems" are stored as binaries in directory ~/.local/share/gvfs-metadata.

So you need gvfs-bin Install gvfs-bin for this to be able to extract them and save them. Oh and there is one file per partition/volume/directory/file (to make things worse).

To get info on an emblem you can use:

gvfs-info -a metadata::emblems {filename|folder}

To set an {icon} for a {filename} or {folder} you use:

gvfs-set-attribute -t stringv {filename|folder} metadata::emblems {icon}

Example:

I created folders 1, 2, 3, 4 in ~/Music.

im1

Commands inside the terminal of the image:

gvfs-set-attribute 1 metadata::custom-icon file:///usr/share/pixmaps/gnome-log.png

gvfs-set-attribute 2 metadata::custom-icon file:///usr/share/pixmaps/gnome-spider.png

Change the 1 and 2 to an existing video file or any other actual file and it should work the same.

and F5 updates the bottom panel.

As you can guess from directory 3 and 4 you will need to do this for every file you want this for.

Here's a script that walks through a directory and sets a PNG that resides in the folder as the folders emblem (basically this mimics Windows method of using folder.png as the emblem of the directory above it).

#!/usr/bin/python

import os
from os.path import join

cwdir = str(os.popen('pwd').readline()).replace('\n','')

for root, dirs, files in os.walk(cwdir):
    for name in files:
        if name.lower().find('.png') != -1:
            os.system('gvfs-set-attribute "'+root+'" metadata::custom-icon "'+name+'"')

You might be able to change this into your own version that includes files.

usage of script at own risk

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.