DirColor

Title DirColor
File Name DirColor.txt
Description Set directory color depending on its contents
Author Vochomurka
Parameters %P
Plugins Called win, ini, file
Icon
Version 1.0
Updated on 29.08.2007
args Path

local hwnd = win.handle("c=TTOTAL_CMD")
local IniFile = pprofolder ++ "scripts\ini\DirColor.ini"
local Masks = ini.enum_keys(IniFile, "Colors")
local MCounter = line(Masks, 0)
local Dirs = file.listfiles(Path, 4)
local DCounter = line(Dirs, 0)
local i, j, OneDir, OneMask, OneKey
local Desc = file.open(Path ++ "descript.ion", "w")

if(Desc <= 0) do
	messagebox("ok error", "File not opened", "FILE plugin error")
	quit
endif

for(i = 1; i <= DCounter; i++)
	OneDir = line(Dirs, i)
	for(j = 1; j <= MCounter; j++)
		OneMask = line(Masks, j)
		if(file.validpath(OneDir ++ "\" ++ OneMask)) do
			OneKey = ini.get(IniFile, "Colors", OneMask)
			file.writeline(Desc, file.nametype(OneDir) ++ " " ++ OneKey)
		endif
	endfor
endfor

file.close(Desc)
win.sendmessage(hwnd, 0x400+51, 540, 0)

Comments:

In brief, this script allows to colorize directories in accordance with files containing in them. Script usage requires three preliminary steps.

Step one. Create saved search with two mandatory features: on the "Advanced" tab you should specify that this search is related to directories rather than files:

Also, on the "Plugins" tab you must specify the following:

Here "Green" is a color name for this search.

So created search is saved as GreenDir.

Step two. Create the DirColor.ini file (or take mine) located in scripts\ini\. For example, if PowerPro installation path is d:\Utils\PowerPro, then the configuration file must be d:\Utils\PowerPro\scripts\ini\DirColor.ini.

This file can contain any number of strings like this:

mask=keyword

where mask can be any file mask (e.g., *.doc), keyword is a color filter ("Green" in our case).

Step three. Define a color for saved search "GreenDir". If you forgot, it can be done through Configuration\Colors\Define colors by file type

Now, when the script is executed, the current path subdirectories are searched for files with masks given in DirColor.ini. If some mask is found, the corresponding keyword is added to descript.ion as a comment for this directory. It means that it will be colorized as the user wants.


Main Page Total Commander PowerPro