Color your folders in Xplorer2

Discussion & Support for xplorer² professional

Moderators: fgagnon, nikos, Site Mods

User avatar
IneedHelp
Gold Member
Gold Member
Posts: 620
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Color your folders in Xplorer2

Post by IneedHelp »

#############################################

IF YOU ARE INTERESTED IN FOLDER COLORING/MARKING, GO TO THIS THREAD:

Setting Colored Folder Icons in x2 (User Command Friendly)

Kilmatead developed a free fully-featured utility that integrates perfectly with xplorer2.

What comes next is obsolete.

#############################################

Youtube: Folder Colors in Xplorer2[720p]
NOTE: this video isn't about Kilmatead's folder coloring application, it shows how an early poor script of mine works. If I'll make a video about Kilmatead's application, I'll post it at the top.

ImageImage

I did request this for v2, but I can't wait until v2's out and there's no guarantee that this will ever be implemented. I'm using ShellToysXP to color folders the way I want, and I do that a lot (gives them more meaning at a quick glance), I do it so often that I got tired of right-clicking a folder and then selecting the desired color from a sub menu.

Another disadvantage of using the contextual menu (for the ShellToysXP entry) to color a folder is that it reinitializes all drives (in my case it wakes up 4 external drives, and I don't want that every time I color a folder).

For those of you interested to color your folders, here's a macro scheduler script I prepared yesterday:

Code: Select all

//Constants.
Let>const_iconhue=60

//Set System variables.
  Let>RP_WINDOWMODE=0
  Let>RP_WAIT=1
  
//Clear clipboard.
  PutClipBoard>0

//Copy folder path to clipboard.

  Press LALT
  Send>c
  Release ALT
  Wait>0.2
  
//Save clipboard path to variable.
  GetClipBoard>folderpath
  WaitClipBoard
  
IfDirExists>folderpath

  //Delete existing icon.
    RunProgram>cmd /c del "%folderpath%\d_cfiicon_*.ico" /f
    RunProgram>cmd /c del "%folderpath%\d_cfiicon_*.ico" /f /a:s
    
  //Copy icon file to destination folder.
    RunProgram>cmd /c echo f| xcopy "C:\Users\mihais13\AppData\Roaming\CFi ShellToys\FolderColor\%const_iconhue%.ico" "%folderpath%\d_cfiicon_%const_iconhue%.ico" /c /f /h /i /q /k /r /y
    RunProgram>cmd /c attrib -A +H +S "%folderpath%\d_cfiicon_%const_iconhue%.ico"
    
  IfFileExists>%folderpath%\desktop.ini
  
    EditIniFile>%folderpath%\desktop.ini,.ShellClassInfo,IconResource,d_cfiicon_%const_iconhue%.ico
    
  ELSE
  
    //Create desktop.ini
      WriteLn>%folderpath%\desktop.ini,nWLNRes,[.ShellClassInfo]
      WriteLn>%folderpath%\desktop.ini,nWLNRes,IconResource=d_cfiicon_%const_iconhue%.ico
      RunProgram>cmd /c attrib -A +H +S "%folderpath%\desktop.ini"
    
  ENDIF
  
  //Set the attributes.
    RunProgram>cmd /c attrib +R "%folderpath%"
  
ELSE

  MessageModal>Please highlight a folder then run the script again.
  
ENDIF

Exit>0
This one is for coloring the folder RED.

To make this work you need the following:
1. Icons for coloring your folders. You can get them from here;
2. Change this path "C:\Users\mihais13\AppData\Roaming\CFi ShellToys\FolderColor" to the path where you have extracted the icon files;
3.Change the value 60 (from this line: Let>const_iconhue=60) to the corresponding value of the color you wish to assign to your folder (check the .ico files for the correct values);
4. And of course you either need Macro Scheduler installed or this script compiled.

Then you can run the script as an user command (e.g. > C:\Users\mihais13\DOCUME~1\MACROS~1\FOLDER~1.SCP)

I don't want to provide by default any compiled script (never trust users on the Internet : D ), but if you really want this and you have no way of compiling it you can tell me and I'll upload a compiled version of it and PM it to you (don't forget to tell me the path to the icon files folder).

Maybe some of you don't even need Macro Scheduler and prefer to write your own scripts, that's OK, I hope the provided script will save you some time (they're mostly DOS commands).

Here's a video I recorded for you to see how this looks in xplorer2. It's in HD so watch it FullScreen!

Youtube: Folder Colors in Xplorer2[720p]
Last edited by IneedHelp on 2011 Jun 07, 07:30, edited 4 times in total.
User avatar
nikos
Site Admin
Site Admin
Posts: 16296
Joined: 2002 Feb 07, 15:57
Location: UK

Post by nikos »

i thought that would be the first youtube video on xplorer2 but there are more!
Kilmatead
Platinum Member
Platinum Member
Posts: 4797
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Post by Kilmatead »

Just out of interest, as you seem to be destroying the old .ini and creating a new one, wouldn't this have the unintended side-effect of wreaking any of x2's previous injections into desktop.ini, such as:

Code: Select all

[.ShellClassInfo]
ConfirmFileOp=0
x2PaneStyle=32785
x2SortInfo=0100000001000000FFFFFFFFFE
x2SortInfoLength=12
x2Groupped=0
IconResource=C:\Windows\system32\SHELL32.dll,303
Why not just write a script to filter the known ini contents and replace only the elements deemed necessary, thus preserving continuity when used on existing folders, rather than only for new ones?  Or did I read that wrong?
Kilmatead
Platinum Member
Platinum Member
Posts: 4797
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Post by Kilmatead »

nikos wrote:i thought that would be the first youtube video on xplorer2 but there are more!
Yeah, but his has the best music. :wink:
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 620
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Kilmatead wrote:Just out of interest, as you seem to be destroying the old .ini and creating a new one, wouldn't this have the unintended side-effect of wreaking any of x2's previous injections into desktop.ini
You're right. I wasn't aware of that kind of entries injected by xplorer2 as I've never seen them before. I'll be fixing the script right away.
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 620
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Post by IneedHelp »

Thanks to Kilmatead for suggesting improvements to the script.

I've deleted some lines, changed others and added some new ones. Here's the new block of code:

Code: Select all

  IfFileExists>%folderpath%\desktop.ini
  
    EditIniFile>%folderpath%\desktop.ini,.ShellClassInfo,IconResource,d_cfiicon_%const_iconhue%.ico
    
  ELSE
  
    //Create desktop.ini
      WriteLn>%folderpath%\desktop.ini,nWLNRes,[.ShellClassInfo]
      WriteLn>%folderpath%\desktop.ini,nWLNRes,IconResource=d_cfiicon_%const_iconhue%.ico
      RunProgram>cmd /c attrib -A +H +S "%folderpath%\desktop.ini"
    
  ENDIF
For those interested, I've updated the complete script in the 1st post.
User avatar
pschroeter
Silver Member
Silver Member
Posts: 283
Joined: 2007 Jan 27, 00:46

I would like to be able to colorize folders in x2 but...

Post by pschroeter »

I would like to be able to colorize individual folders in x2 but I've settled for just coloring the background of their text labels with the Custom color coding dialog.

I remember back in the middle nineties when I was on a Macintosh and you could change folder and any other icons just by pasting an icon into their Properties dialog. I think the Mac called Properties "Get Info."
User avatar
IneedHelp
Gold Member
Gold Member
Posts: 620
Joined: 2010 Feb 04, 02:15
Location: MeanWhile City

Re: I would like to be able to colorize folders in x2 but...

Post by IneedHelp »

pschroeter wrote:[...]but I've settled for just coloring the background of their text labels with the Custom color coding dialog.
I too use color coding, but to globally identify different file types or large files with ease. The only color coding I'm using for folders is for junctions. I don't find it practical to color folders based on name patterns.
pschroeter wrote:I remember back in the middle nineties when I was on a Macintosh and you could change folder and any other icons just by pasting an icon into their Properties dialog. I think the Mac called Properties "Get Info."
Manually pasting an icon file, using a properties sheet or just right-clicking a folder and going to a sub-menu to select an icon is all too much trouble for me these days. The most convenient way is to just have the folder highlighted and then push a button from the tool-bar.

If you're interested, I improved the code displayed on the first post:

Code: Select all

//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

//Script parameters.
  Let>iconfolderpath=C:\Users\mihais13\AppData\Roaming\CFi ShellToys\FolderColor
  Let>iconprefix=desktop_
  //Icon file name used as external parameter.
    //Let>iconfilename=0
  
//If the requested icon file exists:
IfFileExists>%iconfolderpath%\%iconfilename%.ico

  //Continue reading the script.
  
ELSE

  //Display error message.
    MessageModal>[ERROR: Icon not found] Copy requested icon to %iconfolderpath%
    
  //Exit script.
    Exit>0
  
ENDIF

//Set System variables.
  Let>RP_WINDOWMODE=0
  Let>RP_WAIT=1
  Let>CF_OVERWRITE=1
  
//Clear clipboard.
  PutClipBoard>0

//Copy folder path to clipboard using the default xplorer2 shortcut LeftALT+C.
  Press LALT
  Send>c
  Release ALT
  Wait>0.2
  
//Save clipboard path to variable.
  GetClipBoard>folderpath
  WaitClipBoard
  
//If the folder path is valid:
IfDirExists>folderpath

  //If there are previously generated icons:
  IfFileExists>%folderpath%\%iconprefix%*.ico
  
    //Delete existing icon(s).
      DeleteFile>%folderpath%\%iconprefix%*.ico
      
  ENDIF
    
  //Copy icon file to destination folder and set attributes.
    CopyFile>%iconfolderpath%\%iconfilename%.ico,%folderpath%\%iconprefix%%iconfilename%.ico
    RunProgram>attrib -A +H +S "%folderpath%\%iconprefix%%iconfilename%.ico"
    
  //If desktop.ini exists:
  IfFileExists>%folderpath%\desktop.ini
  
    //Edit desktop.ini
      EditIniFile>%folderpath%\desktop.ini,.ShellClassInfo,IconResource,%iconprefix%%iconfilename%.ico
    
  ELSE
  
    //Create desktop.ini and set attributes.
      WriteLn>%folderpath%\desktop.ini,nWLNRes,[.ShellClassInfo]
      WriteLn>%folderpath%\desktop.ini,nWLNRes,IconResource=%iconprefix%%iconfilename%.ico
      RunProgram>attrib -A +H +S "%folderpath%\desktop.ini"
    
  ENDIF
  
  //Set folder attribute to Read only.
    RunProgram>attrib +R "%folderpath%"
  
ELSE

  //Display error message.
    MessageModal>[ERROR: Path not found] Highlight a folder first, then run the script again.
    
  //Exit script.
    Exit>0
  
ENDIF

//Clear clipboard.
  PutClipBoard>0
  
//Exit script.
  Exit>0
Here's a better vew of it:
Image

The best part about it is that I you can set iconfolderpath, iconprefix and iconfilename as external parameters for the script (if you comment them out in the script), so you can specify your own folder holding the icons, whatever icon prefix  and icon file you want to use.

The next step is to make it work for multiple highlighted folders simultaneously.
Can't wait to celebrate the day some virgin chick gave birth to a raptor.
Kilmatead
Platinum Member
Platinum Member
Posts: 4797
Joined: 2008 Sep 30, 06:52
Location: Baile Átha Cliath

Post by Kilmatead »

As a little violent competition is always a healthy thing...

Image

...interested users can also check out a slightly more fully-featured solution here.  (I'm the bloke with the sword who appears to be winning. :D  Though God knows who my medieval tailor was.  A cape?  What was I thinking?)