Setting Colored Folder Icons in x2 (Revisited)

A collection of especially useful xplorer² topics and ideas. New users may find it helpful to look here before searching the other forums for information. >>>>>> Please post new material in the relevant forum. (New stuff posted here will be removed.) Thanks. -fg-

Moderators: fgagnon, nikos

Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

This utility for easily applying bespoke icons to folders was originally written a few years ago, but was in dire need of revisiting... so, one thing led to another and I just decided to rewrite the whole thing from scratch, making it finally what it should have been in the first place.

First off, let me say that while I am aware that there are multiple utilities out there (of varying quality) which do the same thing, few of them allow for extensive customisation options, and so rely solely on their context menu entries (again, of varying quality) to be the main interface. Also, even fewer of those utilities, even the free ones, are completely open-source, so the user is entirely reliant upon the developer to accede to specific requests.

Image

Download Link: SetFolderColour2 (version 2.7.1.7, size: 1.9 MB, updated 05-Aug-14)
RAR includes x86 and x64 EXE's, full source code, and basic icon sets

Ok, so what's so new about it? Doesn't it just do the same bloody thing as it did before?

Well yes, the basic functionality is much the same, but how it does it has been completely updated and improved, alongside a multitude of other changes. For example, now the icons update in the shell instantaneously, rather than the user needing to wait for divine inspiration spending the afternoon refreshing the display like some demented character in a Beckett play. Other changes include a wholly new popup menu (for selecting the icons from a user-command, as seen above), and two different types of shell context-menus for those who prefer that approach.

Can I easily add my own icons if I don't like yours?

Yes you can, just add whatever ICO files you want (up to 250 of them!) into the Icons folder in the utility's directory and they will automatically show up in the selection list (popup/context menus). What's more, you can rearrange the menu any way you like - if you want some icons to be in their own sub-menus, just create some subfolders (named whatever you want), and add the icons there. The subfolder name becomes the submenu name as you would expect. The hierarchy only extends to the first-tier in depth (any subfolders of subfolders will be ignored), which may seem somewhat limiting, but considering the menu structure is updated anew instantly whenever you add/remove/rename or move the icons, I tried to keep it as simple as possible. (The icons in subfolders can also be amalgamated into a single large menu [no submenus] without needing to move anything physically, just ticking a box in the options.)

In fact, I intentionally provided a "mess of icons" by default just to give the user an idea of how things can be arranged - people may simply delete any or all the icons they don't like, and use a set they prefer themselves.

So, knowing you, I suppose there's all sorts of wacky options, yeah?

:D I always do my best.

Image

"x2 Integration"? What's that about? Does this mean I can't use it from Windows Explorer, or other file-managers?

Not at all - this utility may be used however you wish, and will work fine from Windows Explorer or any other way you interact with folders (we ask no questions around here). It's just that I was experimenting with a few things, and decided to add a few key options which optimise its integration within x2. That is, after all, why we're here, isn't it? :D

I suppose there's some command-line stuff in there too in case things go bump in the night?

Oui monsieur, what would a utility be without command-line options? :wink:

Image

Ok, I like what I'm hearing so far - how do I use it?

Well, if you want to use it as a x2 toolbar button, just make a user-command as follows and add it to a toolbar. (You must use the $A token [or '/List=$>' if you're more adventurous], because the utility requires full paths to work properly.) And don't forget the '/Menu' part - that's really really important.

> "SetFolderColour2.exe" $A /Menu

When you click the button, the menu will open up and away you go - at the bottom of the menu there is a <Configure> entry which allows quick-access to the options screen shown above, so you never need to go near the command-line again, if you don't want to. :wink:

If, on the other hand, you only want to use one of the shell context-menu options, just run the EXE and the options window will open up and you may select one at the bottom of the window. These menus do not require Admin access (unlike the original utility) and so may be easily added/removed simply from checkboxes. If anyone is still using the context menu from the original utility, it must be removed (from within that old utility) before using either of these shell entries.

So - umm - dumb question, but why are there two context-menu entry styles?

I'm just being weird and offering people more options than they know what to do with - one uses the "popup"-style (same as the user-command [above], just available from the right-click menu instead of a toolbar); and the other is the more traditional "cascading" entry (from the original utility). Unfortunately both of them have their drawbacks - for example, you may only select one folder at a time to modify... if you select more than one the others will be ignored. This is a just a limitation of how static shell entries work, and there's not much I can about it without leaping off the cliffs of Dover in a fit of anguish and angst. If you want to be able to modify multiple folders at once, use the user-command approach - that one can process thousands of folders at once if necessary, and has no limitations whatsoever.

Also, the cascade-style is very limited in its functionality - if left up to me I would just deprecate it completely and let people fend for themselves, but I left it in for those who prefer it. Basically it's limited to Win7+ only, may only contain up to 12 icons entries, cannot have submenus, and does not have a "Subfolder Recursion" toggle-option like the other menus. This is just life - I highly suggest using the popup-style menu (it does not suffer the same limits as cascade, except for the 1-folder per selection thing) - it can contain as many icons as you want, works fine in XP, and is fully functional with all the swish and swagger it can muster.

Does this modify the 'desktop.ini' files which ordinarily control such things? Will this interfere with anything else which also utilises those files?

It uses Windows' own API functions to access the ini's (which is the way it should be done), which means it's 100% kosher, halal, permissible, legal, and fully paid up with its union dues. This will not interfere with anything (except, obviously, any other programmes which take it upon themselves to change folder icons - but that's the user's responsibility).

What does the option "Create and reference an in-folder hidden copy of the icon (relative path)" actually do, and why would I want to do it?

In the interests of portability, normally if you wanted to move a folder with a bespoke icon to another computer it would not really work, because most icon-references are to files somewhere on the original computer. Using this option will always create a "copy" of the selected icon within the folder itself (and set its attribute to "Hidden"), which will then become the icon which is referenced - in other words, the "icon" to be used is always available because it's held within the folder itself, no matter where that folder is moved to.

A special option is available pertaining to subfolder recursion - wherein either every single folder and subfolder receives it's own copy of the original icon, or whether only the base-folder receives an actual copy, and all subfolder references are relative to that one. This way the base-folder becomes portable, but the individual subfolders are not, if taken separately.

The only real drawback for using these options is the extra space the icon itself takes up - especially in the case of subfolders - for example, if there are 1000 subfolders in your Music folder, and you create a hidden duplicate icon in each one of those (and the base folder itself), that can add 1001 duplicated icon-files into the folder structure, which is a bit extreme.

These hidden duplicate-icons are always removed if the folder is "cleaned" (reset to plain icon) or the icon is itself changed again by the user - the hidden duplicate file will become the new icon instead. Hence only a single icon-file exists within a folder at any given time, mitigating the potential bloat.

I know you have a whole configuration modal, but are there any more "advanced" options for strange people who wake up in the middle of the night with nothing better to mess with?

Indeed there are. Just open the <Configure> window, and press <F2>, and all will be revealed. Be aware that I do not recommend changing these options unless you know what you're doing, but (as usual) they're there if you really want them and don't feel like editing the INI manually. :D

Image

I notice there are two executables in the download, do I need to worry about which one I use?

Not really, they both do the same thing (obviously), but the x64 version will display faster if you populate menus with large numbers of icon-entries (anything above 50) and have an x64 OS. Other than that, you won't notice a difference and can safely just delete the one you don't use.

Any last words?

I could babble on about minutia, but that about covers it.  If you have any questions, requests, or criticisms, feel free. :D  I hope it proves useful to somebody.  (And yes, for those who know me, I do have a slightly odd taste in my mouth from creating what could be seen as a more "mainstream" utility - have no fear, I won't make a habit of it. :roll:)

Enjoy or dismiss as you may.

I would like to specially thank the forum member dunno for climbing down off his hammock long enough to provide extensive testing on Windows XP and for finding a couple of bugs which threatened the very essence of western civilisation itself (as far as my understanding of x2 tabs is concerned). Thanks again. :beer:
Last edited by Kilmatead on 2017 Mar 15, 19:40, edited 15 times in total.
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

Ok, this utility (and the original post in this thread) have been completely rewritten to reflect a massive new update (to 2.6). All questions should be answered by the main post (including all new screenshots for the dozy users), and most of the options are self-explanatory (at least in my opinion).

Download available in the original post. (Be sure to remove the old context menu from within the original utility before moving to this version, if you are using that option.)

Changelog:
  • Icon changes are now represented in the shell instantaneously (via WinAPI 'SHGetSetFolderCustomSettings')

    Shell context menu no longer requires Admin privileges to create/remove or change settings (the menu from the old version must be removed before the new one may be activated)

    Alternative 'popup menu' available as seamless substitute for the 'cascading' context menu (available for all systems, including XP and Vista)

    First-tier subfolders found in the IconsFolder may become submenus themselves, or may have their contents amalgamated into a single menu

    Inclusion of relative-path hidden icon duplicates improved (icons may now be automatically extracted directly from EXE's and DLL's as part of the assignment flow)

    Persistent settings across both menus accessed via INI rather than registry

    Popup menu has a limit of 250 entries (via IconFolder contents)

    Settings Configuration is available directly from within the menu itself
Enjoy.
Shafranek
New Member
Posts: 2
Joined: 2014 Jan 10, 21:40

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Shafranek »

Emm... And what about "Apply icon to all sub-folders as well" option? Is it available?
UPD. Sorry, Now I see, I have to use "Ctrl" to make it :)
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

Yes, it's a toggle-entry in the popup-menu, just above the <Configure> entry at the bottom. Click it and <Subfolders Enabled> becomes active, with special attention applied to whether or not the target-folder holds a duplicate icon file, or all folders receive their own, or just a standard reference in each folder is applied as usual.

Subfolder-recursion is also available in the "cascade"-style context menu, but you have to hold <Ctrl> when you make a selection (as you discovered). (This applies to the Popup menu as well, but since that has a built-in menu-option you don't need to remember it.)

People should be careful with this option, as it is quite capable of modifying literally all the folder icons on a whole drive in one go, if applied accidentally to the drive-root. :wink:
dmattote
Member
Member
Posts: 20
Joined: 2009 Jul 28, 03:41

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by dmattote »

Greetings Kilmatead. I have used SetFolderColour for a long time but this new version SetFolderColour2 is presenting me with problems. I would appreciate any help you could give me. To begin with I tried to use the older @SFC variable to access my icons and that doesn't seem to work however I can use the %XDIR% environment variable and that works. My icon files (all .ICO files) are in a subfolder called /Icons off of my /Tools Xplorer2 subdirectory. What exactly is the syntax for the /ICON parameter? This, however, is not the main problem. In every case, despite the fact that I am not creating an ICON file in each folder that is colored, I receive the error message "Failed to update folder-icon resource." If I choose the Ignore option when this error shows it changes and updates the folder icon properly. I really don't need to see the error message every time I color a folder. For reference I am using Win XP SP2 (I know that's a little old but so am I.) Thanks in advance.
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

The @SFC variable was deprecated for the new version (I didn't know anyone actually used it!).

Are you using this specifically for one icon per toolbar button (the "old way"), or (as it should be used) as the new popup menu? This version is basically designed for the popup menu (which is compatible with XP), so try that first, please. Just make a user command as:

> SetFolderColour2.exe $A /Menu

...and see if that works for you (assigning icons, etc, without errors). It should open a menu which looks rather like the one in the screenshot in the first post. Once we verify that that method works, if you still wish to use it without the menu (you strange ungodly heathen, you :wink:), we'll do some digging to find out what the problem might be.

The first time the menu appears, click "Configure" for the option to point the icons folder to your specific location as desired.
dmattote
Member
Member
Posts: 20
Joined: 2009 Jul 28, 03:41

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by dmattote »

Hello again. I did use the SFC variable as it happens, but that's no big deal. I can even use the context menu method and, indeed, use it however even using the menu I get the error message I cited for every folder that the utility attempts to colourize. One other strange behavior: I attempted to colourize more than one folder having checked the option to create the hidden icon in each folder. The error message occurred for every folder yet, choosing Ignore every time the utility only colourizes the first folder. Also, On colourizing a single folder I tried a test by setting the $Ret variable to 1 just below where the icon is assigned so the utility would not read the error and that seemed to work.
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

dmattote wrote:I tried a test by setting the $Ret variable to 1 just below where the icon is assigned so the utility would not read the error and that seemed to work.
That was going to be plan 'B'. :wink: I have no idea why XP is returning that error each time (the same API call does not do it on other platforms, nor did it occur on XP during testing). I added the error-checking more for those folders which the user may not have access-rights, as it serves a purpose there - but for normal folders the icon is either applied or it's not, so the user knows if it worked and doesn't need to be told. If others encounter this problem I may add a suppression method.

Unfortunately I have no access to an XP machine, so can't do anything specifically for it. The odd part is that that particular API call doesn't usually even return an accurate error (even if there is an actual error) so it's mostly hit and miss. (It's not AutoIt either... I tried a rudimentary version in C and it tends to ignore even forced errors as well, so it's just the API being weird.) :shrug:

Since you seem happy enough to go tinkering in the code, feel free to play with it (or just rip it out completely) - you can't really hurt anything on the folders themselves. There's also no reason multiple-folders fail, though if you're referring to subfolders, recursion is automatically disabled if the parent-folder fails (and "Ignore" is used), but it should only apply to a single branch, not all "selected" parents.
Enternal
Member
Member
Posts: 54
Joined: 2013 Aug 03, 05:28

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Enternal »

WHAT IS THIS SEXY LOOKING PROGRAM FOR XP2?! *INSTANT DOWNLOAD
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

One day I'll be able to release a mod like this for x2, but I haven't figured out the physics of it just yet - only the young can be that honestly enthusiastic about such a simple thing.

I mean, what a fabulous name for an extension. :wink: <Sigh>
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

Just a small update to 2.6.0.3 fixing persistent invalid handle errors in XP, and a preservation of any user-set [S] attribute. Thanks to forum member vserghi for his ablutions to the cause. :wink:
User avatar
nikos
Site Admin
Site Admin
Posts: 15759
Joined: 2002 Feb 07, 15:57
Location: UK
Contact:

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by nikos »

did you test on win98?
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

I am imperturbable to your jibes. Phlegmatic to your worries. Indifferent to your citrus fruits. Like this guy, I barely raise an eyebrow to your trials and tribulations...

Image

(I'm serious, watch his right eyebrow as he gets pelted by goo...)
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

An update to 2.6.0.7 (link in original post above) concerning:
Changelog wrote:; Reparse-Points (Junctions, SymLinks, and Mount-Points) are now properly handled and may be optionally 'Followed', 'Queried' (for following), or 'Ignored' automatically
; - Links are processed as their literal targets (Mount-Points are shown as their actual drive-letter path, not as the less helpful GUID text, etc)
; - Junctions and SymLinks may optionally reflect their targets' new icon if assigned via the link itself (will not interfere with overlays)
; - Mount-Point roots will never be assigned an icon, though they may become containers for hidden-duplicate icons if recursion-references are relative-to-base for the whole of the tree
; - Reparse-Chains (direct links to other links) are not supported
; - If Reparse-Points are set to be 'Ignored' and one or more is specifically targeted by user-selection they are treated as 'Queried' (those encountered via recursing are ignored as expected)
; Relative paths are accepted: /Icon (relative to Icon-Folder), /Query (to Icon-Folder), /INI (to programme-folder), /List (to programme-folder), and any '.lst' contents (to current-file)
; Fixed: Superfluous x2 auto-refreshing when no visible objects were actually modified
; Fixed: <Select Custom File> opening location sometimes had a mind of its own
; Fixed: Modified timestamps of drive-roots weren't preserved as expected (Wait, do drive-roots actually have timestamps? Why yes, yes they do! NTFS only)
; Fixed: Non-unique folder submissions weren't stripped
Kilmatead
Platinum Member
Platinum Member
Posts: 4569
Joined: 2008 Sep 30, 06:52
Location: Dublin

Re: Setting Colored Folder Icons in x2 (Revisited)

Post by Kilmatead »

Yet another update (to 2.6.0.9) fixing multiple small issues, not least of which was the terrible rendering of focused-icons in the popup under all XP themes (and any non-Aero Vista/Win7+ themes). This distortion didn't impede functionality, but made the menu rather distracting to use.

Updated link in original post, full changelog is in the source-code.

"In theory," mused the creator, "this should be about finished now." :roll:
Post Reply