|
Title | FindExclude |
File Name | FindExclude.txt |
Description | Exclude files/directories from search |
Author | Vochomurka |
Parameters | - |
Plugins Called | win, ini, vec, childwin |
Icon | |
Version | 1.1 |
Updated on | 05.02.2008 |
local CR = esc(?+\r+, ?+\+) local Quote = esc(?+"+, ?+\+) local hwnd = win.handle("c=TTOTAL_CMD") ;"\ini\" - subdirectory of scripts created manually local Settings = scriptfolder ++ "\ini\FindExclude.ini" local Files = ini.enum_keys(Settings, "Files") local FileCounter = line(Files, 0) local Dirs = ini.enum_keys(Settings, "Dirs") local DirCounter = line(Dirs, 0) local Result, Str, i, Temp FMask = vec.create(FileCounter) if(FMask == 0) do messagebox("ok error", "Vector not created", "VEC plugin error #1") quit endif DMask = vec.create(DirCounter) if(DMask == 0) do messagebox("ok error", "Vector not created", "VEC plugin error #2") quit endif for(i = 1; i <= FileCounter; i++) Temp = line(Files, i) Str = ini.get(Settings, "Files", Temp) FMask[i - 1] = Str Result = Result ++ "Files: " ++ Quote ++ Temp ++ Quote ++ ", mask: " ++ Quote Result = Result ++ Str ++ Quote ++ CR endfor for(i = 1; i <= DirCounter; i++) Temp = line(Dirs, i) Str = ini.get(Settings, "Dirs", Temp) DMask[i - 1] = Str Result = Result ++ "Directories: " ++ Quote ++ Temp ++ Quote ++ ", path: " ++ Quote Result = Result ++ Str ++ Quote ++ CR endfor pickstring(Result, "Pick Item(s) to Exclude", 1) DirCounter = word(_pickedline_, 0) if(not _pickedline_) quit Files = ifelse(ini.get(Settings, "Options", "Asterisk"), "*.* |", "|") Dirs = "" for(i = 1; i <= DirCounter; i++) Temp = word(_pickedline_, i) if(Temp <= FileCounter) do Files = Files ++ " " ++ FMask[Temp - 1] else Dirs = Dirs ++ " " ++ DMask[Temp - FileCounter - 1] ++ "\" endif endfor vec.destroy(FMask) vec.destroy(DMask) Str = Files ++ Dirs win.postmessage(hwnd, 0x400+51, 501, 0) Temp = ini.get(Settings, "Options", "FileDir") wait.for(activewindow("c=TFindFile")) Files = win.handle("c=TFindFile") if(Temp != 2) do keys +{tab}{right}{tab 4}{space}{tab 2}{space} if(Temp) keys {space} keys {tab 6}{left} endif Dirs = childwin.handle(Files, 23) win.settext(Dirs, Str) for(childwin.gettext(Dirs) != Str) win.settext(Dirs, Str) endfor if(ini.get(Settings, "Options", "StartNow")) keys {enter}
At seaching files it is convenient to exclude specific files and directories. It allows to avoid, first, loss of time, and second, unwanted information in the results. For example, before searching some text string it is suitable to exclude multimedia files and, for example, the whole Photoshop folder.
Total Commander provides so-called saved searches. However, if some saved search excludes five directories, and we would like to include two of them? Editing "Search for" field and/or "Plugins" tab settings can be too boring and labour-intensive.
The script presented allows to compose the exclude list just prior to run the search process.
First of all you should customize the configuration file. You can just create it or take mine as an example. If PowerPro is installed to, say, c:\Program Files\PowerPro, then the full path to the configuration file must be c:\Program Files\PowerPro\scripts\ini\FindExclude.ini.
[Options]
FileDir=0
;0 - files only, 1 - directories only, 2 - all
Asterisk=0
;if 1, type *.*
StartNow=0
;if 1, start search immediately
[Files]
Graphics=*.jp?g
Executable=*.exe
Movie=*.mpg *.wmv *.avi
[Dirs]
VisualStudio=VStudio
Bins=Recycle?
Meaning of the [Options] section keys is explained in comments.
Keys of section [Files] are file descriptions, key values - corresponding masks. Each value can include several masks separated by spaces.
Values of the [Dirs] section have some peculiarities. First, they should not be full paths but folder names only (wildcards ? and * are valid). Second, each key should have one value only.
When you have added all files and directories you would often exclude from search, the script is ready to be executed. Then choose any files and directories from the list and click OK.
All Scripts | Total Commander | TotalCmd.net | PowerPro |