DonationCoder.com Forum

DonationCoder.com Software => Coding Snacks => Post New Requests Here => Topic started by: doctorfrog on February 01, 2008, 07:07 AM

Title: DONE: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 01, 2008, 07:07 AM
This is an idea I had a while back, and blogged about, back when I cared about blogs: http://doctorfrog.blogspot.com/2005/04/wanted-folder-art-collector-software.html

Basically, I want a function similar to the way Windows will sometimes change folder icons based on what's inside them, except I want the .ico or .exe icons present inside the folder to be used instead of icons of stock images of music notes or flowers. This is one of those things that sounds simple to a non-programmer, lucky me if it actually ends up being simple to execute.

There are a few (somewhat more complicated) extensions to this idea as well (consider them nice-to-haves):
- if the resources within the folder are image files, auto-pick one of them and create an .ico from it, then apply as custom folder icon
- offer ability to create rules to apply stock icons based on the majority file types within the folder (ie. if the folder contains mainly .mp3s, apply a certain icon image)
- ability to recurse and apply icons for subdirectories, or only apply to the top tier of directories the application is aimed at
- support for creating/scaling very large icon files, for those persons who pump up their icon sizes beyond 32x32

Here's a copy of my original blog post blatherings:

I wasted some time late last week picking custom icons for some folders on my Windows XP box:

(http://tinypic.com/4hfdkm)

Avoiding actual work, I headed over to my games folder and started doing the same:

(http://tinypic.com/4hfdr9)

And I noticed something. Mostly, to pick an icon, you go to the only .exe in the folder, or the only .exe with an embedded icon, or the only .ico in the folder, and select it as your folder icon. It is a repeated, mechanical process, something that can be handled with a fairly simple program.

Such a program can be sent to crawl among a top-layer collection of folders, crib the most likely icons to be used for the folders, and present them to the user for approval, similar to Album Cover Art Downloader. If no appropriate icons are found, the program can offer a standard selection of icons from a specified .icl or folder full of icons (I'm partial to foood's delicious icons, as shown above).

All of the icons in the second image above exist in their respective folders, and are, in most cases, the only icons in the folder. They'd be ideal for this program, since they can be automatically assigned. If there are other icons in the folders, the program can just pick one and present it, along with alternate icons, for approaval, similar to Album Cover Art Downloader. I keep a bunch of general-purpose icons in a folder, and Windows of course has its Shell32.dll. If no icons are found to autopimp the folder (hey, hey! great software name!), these resources can be presented to the user to hand-pick an icon.

The following logic can be applied to automatically pick the 'correct' icon:
If there is only one icon available (.ico, .icl, .exe), use it. Otherwise: Use the icon with the highest resolution, most colors, etc. (This avoids picking an icon from a .exe that isn't the main program in the folder, since icons designed to represent a program usually contain multiple resolution and color depth versions, and 'helper'programs are often given a more generic icon.)

Does something like this exist? And, am I the only one who thinks it should?
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: jgpaiva on February 01, 2008, 07:19 AM
This can be done, it isn't much of a task and it's pretty cool ;)

The icon of the folder is stored under a hidden system file inside that folder called desktop.ini (http://msdn2.microsoft.com/en-us/library/bb776832(VS.85).aspx).
Thus, changing the info on that file is pretty easy.

Now, the big problem i can see, is when there are several icons/executables on the same folder. Also notice that if you have 2 icons with a different name, they'll be identified as being a different icon even if the image is the same (fixing this isn't trivial).

So... My option would be: for a first version, make it add the first icon/executable it finds or instead, if there are multiple choices, add none. And for a next version, we could add something like a popup asking the user to choose between the icon options on the folder.

Regarding the "extras"... Only the option on recursion is trivial, the first one is complex, the second one is doable (depends on how much attention the app gets), and the fourth one... I don't think i get what you mean :)

What do you think?
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: gogogadgetscott on February 01, 2008, 08:31 AM
I created a VBScript awhile back that does something like this. Let me know what you think. I am happy to revisit it and make updates.
http://gogogadgetscott.info/computers/scripts/iconany.php
[ You are not allowed to view attachments ]

GoGoGadgetScott
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 01, 2008, 10:13 AM
That's pretty decent there, Scott, and embodies my idea well. Barring the production of a formal app, I think I can make do with this. I suppose I could remove the customization by finding all desktop.ini files in a directory structure and deleting them?
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: jgpaiva on February 01, 2008, 10:16 AM
Yep, doctorfrog, deleting the desktop.ini files should do the trick :)
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: BigJim on February 01, 2008, 10:37 AM
Barring the production of a formal app

Having done what you've already done ... why not follow through and create the app? It sounds pretty useful to me!
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 01, 2008, 11:46 AM
If I had the chops, I'd do it :-) However, I am at best a power user. I was just able to figure out how to adjust the script to do it's thing somewhere other than g:\apps (which it does as a default).

Is it possible to compile a VBScript to run as a Visual Basic .exe? If so, you can add in:
- a user prompt for specifying directory
- an option so the user can whether or not it is appropriate to recurse subdirectories
- a cleanup option that runs through and deletes all desktop.ini files, or removes the icon entries in them

If not possible, well, shucks.
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: BigJim on February 01, 2008, 12:12 PM
... well, shucks
Language!! We do have standards here, you know.  :D

I hear what you're saying. But there are lots of nice and talented folks here. One may take the baton. (hint!)  :eusa_dance:
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: gogogadgetscott on February 01, 2008, 12:17 PM
I will happily convert to a desktop Visual Basic app. I like doctorfrog ideas and can easily implement. Does anyone have problem with a .net requirement?
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 01, 2008, 12:49 PM
I can live with it. ;-)
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: jgpaiva on February 01, 2008, 01:10 PM
I just gave it a go with ahk, and had the most frustrating hour ever!

After all, it looks like creating the .ini file isn't enough!!
And it looks like ahk has a huge stupid bug with file-pattern loops!!

Thus, i'm sorry but i can't keep this one.

gogogadgetscott: please do, amaze us! :D
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 02, 2008, 09:30 AM
Another request, if there's room. I realize this one will require some further program logic:

If the first icon resource (exe) the script encounters does not have an icon present, move to the next resource. Good example: 7zip. The directory is full of headless exe's, but the one with the icon resources is the 7zFM or some such.
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: gogogadgetscott on February 04, 2008, 09:07 PM
IconAnyFolder v0.1 - First Release (written in C#)

Features
- a user prompt for specifying directory
- an option loop recursively into subdirectories
- a cleanup option that runs through and deletes all desktop.ini files, or removes the icon entries in them
- If the first icon resource (exe) the script encounters does not have an icon present, move to the next resource.
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: mouser on February 05, 2008, 07:55 AM
Wow this looks great! how did i overlook this thread the first time!

gogogadgetscott, really nice work!  :Thmbsup: :Thmbsup:
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: doctorfrog on February 06, 2008, 12:39 AM
Wow, a guy blinks and look what happens! Thanks a lot, Scott!
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: jojo99 on February 10, 2008, 05:08 AM
Looks like you guys missed this program:
http://qad.dcmembers.com/wp/category/freeware/

I've been using this for a while and it works well.  Compared to te program in this thread, it doesn't loop through folders and sub-folders though.
Title: Re: IDEA: Autopick custom icons for folders based on resources in folder
Post by: jgpaiva on February 10, 2008, 05:17 AM
Now that's interesting... It's hosted on donationcoders and yet i had never heard of it! :)
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: robinsiebler on February 22, 2008, 05:28 PM
It sounds great!  However, I don't actually care about the folders per se.  However, I want to do something similar.  I would like all of the subfolders in my Games start menu to have the actual icon for the game.  I've done this manually for many of them and it is a pain as I have over 50 games installed.
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: nogojoe on February 27, 2008, 02:02 PM
Hi
this is more for gogogadgetscott.

Love your program and I have included a shortcut to the sendto menu on my computer.
when I  right click a folder and get to your program in the send to menu iconanyfolder opens up at the last folder that I had used with iconanyfolder. Instead of opening up with the folder that I had right clicked in the first place.
It means having to scroll through the directories to find the folder that you want to action on.
It would be good if that could be amended at some time as an enhancement.

nogojoe
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: mouser on February 28, 2008, 09:27 AM
this was mentioned on Shell Extension City today -- congratulations to scott and everyone else involved.
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: SirSmiley on February 28, 2008, 05:07 PM
Crap, mouser beat me to it! :D

Anyway Congrat's on the feature.  :Thmbsup:

Your original Vbscript is sexy clean.
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: kartal on March 21, 2008, 11:07 PM
Very nice.
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: kartal on March 21, 2008, 11:10 PM
I also wish that it would not change the modified date of the folder
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: hairball on May 27, 2008, 07:24 PM
Hi all,

I was playing around with this app and changed the background on a folder, and now i can’t read the text in that folder, and wanted to remove the background but cant.
Anybody have any ideas on how to remove the background once it’s been applied?

Thanks!
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: SirSmiley on May 27, 2008, 07:58 PM
Open the desktop.ini file and delete the background image or just delete the desktop.ini file.
Title: Re: DONE: Autopick custom icons for folders based on resources in folder
Post by: Deozaan on May 27, 2008, 08:45 PM
If I turn off the Recursive feature, it won't update a folder. For example, in my games directory where all games are installed, I would like the first directory of a game to show the game's icon, but I don't need it to search every subdirectory for data, music, bin, src etc and change those icons.

But turning off recursive results in 0 folders updated.