Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: How To: Add folder image / folder thumbnails like windows xp

  1. #1
    Join Date
    Aug 2005
    Location
    Athens/Greece
    Beans
    35
    Distro
    Ubuntu 9.10 Karmic Koala

    How To: Add folder image / folder thumbnails like windows xp

    I was trying to find a way to easily add images to a folder like windows xp do. I couldn't find anything so I wrote a little program that does that myself.

    SetFolderIcon looks for an image called Folder.jpg or Folder.png if it finds one then it changes the folder icon to that image. If it doesn't find an image called Folder.jpg or Folder.png then it looks for photos and videos in the folder and creates a folder image with 4 small thumbnails (like win xp).

    WARNING
    This is my first C# code. That means I had to google every single command/function. It doesn't look nice but it works (most of the times). I'm sure/know there are cases I haven't covered and lot of error handling to be done but the program as is works for ~95% of cases. I have tested the program only under Ubuntu Edgy. I've no idea if it works in older/newer versions.

    Instructions:
    1. Extract archive in a folder

    2. Create a folder in your home directory called .FolerIcons (/home/yourlogin/.FolerIcons) and copy bg.png in it.

    3. make sure you have mono, imagemagick and zenity installed
    - sudo apt-get install imagemagick, mono-runtime, zenity

    4. edit SetFolderIcon.sh and replace the path to setfoldericon.exe with the one on your system.

    5. copy SetFolderIcon.sh to /home/yourlogin/.gnome2/nautilus-scripts

    6. Now you can right click a folder -> Scripts -> SetFolderIcon

    In order to view the folder image you must restart nautilus. You can restart nautilus by typing in a terminal: nautilus -q
    I usually sudo killall nautilus

    The source code is included in the archive. if you want to complile it use gmcs.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	sample.png 
Views:	404 
Size:	22.0 KB 
ID:	23259  
    Attached Files Attached Files
    Last edited by JNik; January 17th, 2007 at 12:41 PM. Reason: Added screenshot
    Desktop: AMD64 X4, 200GB & 80GB HDD, 4GB RAM
    Laptop: Acer Aspire 1522WLMi
    Netbook: Acer Aspire One A150L
    Cellphone: HTC Hero

  2. #2
    Join Date
    Oct 2005
    Location
    United Kingdom
    Beans
    4,848

    Re: How To: Add folder image / folder thumbnails like windows xp

    Please be careful when using others 3rd party scripts. I do advise you to understand they work first by reading the source and checking you understand it... maybe even compiling the source yourself.
    Last edited by PriceChild; January 14th, 2007 at 05:11 PM.
    Every time you install Jaunty, a kitten........ wait sorry what year is this again?
    Please don't PM support questions, post a thread so that everyone can benefit
    Join us in #ubuntuforums on irc.freenode.net

  3. #3
    Join Date
    Oct 2005
    Location
    Adelaide, South Australia
    Beans
    746
    Distro
    Ubuntu 11.10 Oneiric Ocelot

    Re: How To: Add folder image / folder thumbnails like windows xp

    i dont understand?..... wit ha default ubuntu dapper install, i can right clikc on a folder, click the big square button that holds the folder icon,......wallah! i can select ..... a custom icon .....small wonders. so what is the purpose of your 'thingy' again? ok...i see now, your genrerating icons from folder contents.
    Fear is the mindkiller....
    The little death that obliterates...

  4. #4
    Join Date
    Aug 2005
    Location
    Athens/Greece
    Beans
    35
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: How To: Add folder image / folder thumbnails like windows xp

    Quote Originally Posted by airtonix View Post
    i dont understand?..... wit ha default ubuntu dapper install, i can right clikc on a folder, click the big square button that holds the folder icon,......wallah! i can select ..... a custom icon .....small wonders. so what is the purpose of your 'thingy' again? ok...i see now, your genrerating icons from folder contents.
    and it can do a batch of folders... no need to do one by one.
    Desktop: AMD64 X4, 200GB & 80GB HDD, 4GB RAM
    Laptop: Acer Aspire 1522WLMi
    Netbook: Acer Aspire One A150L
    Cellphone: HTC Hero

  5. #5
    Join Date
    Aug 2007
    Location
    Netherlands
    Beans
    205
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: How To: Add folder image / folder thumbnails like windows xp

    This one automatically uses a picture if available.
    I have artist music folders, i'm not gonna change them all manually:

  6. #6
    Join Date
    Sep 2009
    Beans
    4

    Re: How To: Add folder image / folder thumbnails like windows xp

    Hey folks

    I upgraded to Karmic and gnome 2.27 is coming with it.

    They changed the metafile system of nautilus to the gvfs system which makes inserting additional meta-infos pretty easy.

    I put together a small python script which automatically takes an image from within the folder and sets it to be the folder image.

    Code:
    #!/usr/bin/python
    
    import os
    
    cwdir = str(os.popen('pwd').readline()).replace('\n','')
    
    for folder in os.listdir(cwdir):         # iterating through current DIR
        if os.path.isdir(folder) == True:        # check if is folder
            for pic in os.listdir(folder):                # iterating over folder content to find usuable picture
                if pic.lower().find('.jpg') != -1 or pic.lower().find('.gif') != -1 or pic.lower().find('.png') != -1: #checking for image
                    os.system('gvfs-set-attribute "'+folder+'" metadata::custom-icon "'+pic+'"')    #setting metadata
                    print folder+": using "+pic             #console output if used in console
    Just put the code in a python file in the nautilus script folder.
    e.g.:

    ~/.gnome2/nautilus-scripts/Dir Pictures.py

    Make it executable.
    You can then run it from the right click menu of nautilus.
    After running you just have to reload the folder.

    It works nicely for me.

    Perhaps it's of use for someone.
    Last edited by cataclysmic; September 18th, 2009 at 04:53 PM.

  7. #7
    Join Date
    Oct 2007
    Location
    Thessaloniki - Greece
    Beans
    13
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: How To: Add folder image / folder thumbnails like windows xp

    Quote Originally Posted by cataclysmic View Post
    Hey folks

    I upgraded to Karmic and gnome 2.27 is coming with it.

    They changed the metafile system of nautilus to the gvfs system which makes inserting additional meta-infos pretty easy.

    I put together a small python script which automatically takes an image from within the folder and sets it to be the folder image.

    Code:
    #!/usr/bin/python
    
    import os
    
    cwdir = str(os.popen('pwd').readline()).replace('\n','')
    
    for folder in os.listdir(cwdir):         # iterating through current DIR
        if os.path.isdir(folder) == True:        # check if is folder
            for pic in os.listdir(folder):                # iterating over folder content to find usuable picture
                if pic.lower().find('.jpg') != -1 or pic.lower().find('.gif') != -1 or pic.lower().find('.png') != -1: #checking for image
                    os.system('gvfs-set-attribute "'+folder+'" metadata::custom-icon "'+pic+'"')    #setting metadata
                    print folder+": using "+pic             #console output if used in console
    Just put the code in a python file in the nautilus script folder.
    e.g.:

    ~/.gnome2/nautilus-scripts/Dir Pictures.py

    Make it executable.
    You can then run it from the right click menu of nautilus.
    After running you just have to reload the folder.

    It works nicely for me.

    Perhaps it's of use for someone.

    Ehm... Nice mate really useful, but i have a little problem... Is there anyway to make it look a bit larger? The thumbnail is very small and there is no outline to indicate that this is a folder and not an image like all the others in the folder?

  8. #8
    Join Date
    Sep 2009
    Beans
    4

    Wink Re: How To: Add folder image / folder thumbnails like windows xp

    Hi Shadowdeath.

    I use it for my movie folders. So I want to see the posters instead of a folder icon. But I consider that idea.

    The size of the image, that is pretty simple:
    Ctrl + + or CTRL + Scroll up

    You can simply zoom the icons in the folder. Nautilus remembers the icon size independently for each folder.

    I hope it helps.

    PS: I think it might be easier just to tag the folder with an emblem. But there is non for "folder" yet. Maybe you have an idea.
    Last edited by cataclysmic; October 21st, 2009 at 07:30 AM.

  9. #9
    Join Date
    Nov 2008
    Beans
    2

    Re: How To: Add folder image / folder thumbnails like windows xp

    New nautilus script!

    Unzip ImageFolder.zip on folder "~/.gnome2/nautilus-scripts"

    I would like to make the icons bigger.
    I also want to make an auto-refresh in nautilus.

    Code:
    #!/usr/bin/python
    
    import os, sys
    import Image
    
    folders = sys.argv[1:]
    im=[]
    crop=[]
    
    def create_bg(p):
        bg = Image.open(os.environ["HOME"]+"/.gnome2/nautilus-scripts/bg.png")
        bg.paste(crop[0],(4,35,64,80))
        bg.paste(crop[1],(64,35,124,80))
        bg.paste(crop[2],(4,80,64,125))
        bg.paste(crop[3],(64,80,124,125))
        bg.save(p+"/.folder_bg.thumbnail","PNG")
        os.system('gvfs-set-attribute "'+p+'" metadata::custom-icon ".folder_bg.thumbnail"')
    
    def get_img(p):
        i = 0
        if os.path.isdir(folder) == True:
            for pic in os.listdir(folder):
                if pic.lower().find('.jpg') != -1 or pic.lower().find('.gif') != -1 or pic.lower().find('.png') != -1:
                    im.insert(i, Image.open(p+"/"+pic))
                    im[i].thumbnail((60, 45))
                    crop.insert(i, im[i].crop((0,0,60,45)))
                    i=i+1
                if i>=4: 
                    create_bg(p)
                    return
                    
     
    for folder in folders:
        get_img(folder)
    Attached Files Attached Files
    Last edited by rodrigocorsi; November 7th, 2009 at 09:41 PM.

  10. #10
    Join Date
    May 2007
    Location
    London UK
    Beans
    107
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: How To: Add folder image / folder thumbnails like windows xp

    My albums are arranged in folders by artist and album, and I have a hidden thumbnail .artist.png in each artist folder and another .album.png thumbnail in each album folder. The attached python script, run from the root folder, will walk the tree attaching each thumbnails to the icon of the folder above. Change .png to whatever graphic format you're using.

    Code:
    #!/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+'"')

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •