[UP]

FF - Fuzzy Filter F*
Download ff.zip

Introduction
FF is a wrapper around ZTree's Filter dialog permitting fast and complex filter entry using the smallest number of keystrokes possible. The resulting "fuzzyspec" is a perfectly legal ZTree filespec, consisting of one or more of the three filespec types (Name, Size, Date). FF is activated by terminating the standard Filter dialog with Shift+Enter, rather than Enter. It thus introduces only one new key combination into the ZTree environment.

FF is a pre-processor with a simple set of rules. It coexists with your usual Filter habits, which, hopefully, consist of regular use of Filter's own wildcarding and excellent command history and bookmarking tools. Each mode has its pro's and con's, but FF has some uniqe time- and work-saving features.

FF prototypes certain ideas that may be of use in ZTree or other file managers. There is no better way to test them than by using them for a while, in whatever form. I use FF as a playground for experimenting with AutoHotkey and ZTree. Both are my favorite productivity tools of equal importance.

FF is written in a scripting language, but can be compiled into an executable for easier deployment. It would probably be more efficient if it were written as a ZAAP (maybe one day...).

Requirements
(1) The string "ZTreeWin" must be present in ZTree's title. By default, this is the case (See section 1. Main Display in ZTW.HLP).
(2) In the current FF version, the ZTree CO1K option must look like " K Date Format yyyy-mm-dd " to make date-related functions work correctly. If this is not your default date format, copy your ZTW.INI to ZTW_TEST.INI and run a ZTW.EXE session with the /ZIZTW_TEST.INI switch. Configure this ZTree session with the above CO1K option and use it for playing with FF. (In a future version, ZTW.INI may be parsed and the format automatically detected, removing this requirement.)

FF Systray icon Installation
Put FF.EXE in any directory and run it once. It will present its About popup and attach itself to all ZTree instances and wait for Shift+Enter to be struck. It is recommended to load FF at Windows startup by creating a shortcut such as: %USERPROFILE%\Start Menu\Programs\Startup\FuzzyFilespec.lnk pointing to FF.EXE. It is independent from ZTree and will remain active whether ZTree instances exist or not.

If you are customizing FF, you must run the script (FF.AHK) under the AutoHotkey interpreter until you are ready to create the executable. Obviously, this requires obtaining and installing AutoHotkey.

From the About popup, you can read the full description on the web (this page), or click on Help for a one-screen quick reference. FF Systray icon

To remove FF from memory, right-click on its systray icon F* and select Exit, or use f\Shift+Enter from within ZTree. FF can also be removed from the About popup with the Unload button.

Remember that the About popup can be displayed at any time with f??Shift+Enter, giving you access to documentation, numerous related links, and the Debug toggle. The f?Shift+Enter is reserved for displaying the quick reference screen (same as clicking on Help in the About popup). You will need to use this a lot in the beginning.

Usage
Once the About popup is closed, FF is ready for use. It works only in ZTree, no other application is aware of it. Use f to enter the Filter dialog as usual. Type a few letters and terminate with Shift+Enter. The letters will be surrounded and interspersed with asterisks. Learn a few short
FF tokens, and you'll get even more relevant hits.

Scope
All ZTree instances share the same fuzzyspec, which is stored inside FF.EXE's memory space and is thus a sort of a one-line global clipboard. This is an interesting feature that you may want to make creative use of.

The standard Filter user input is local to each ZTree session, and the only way to share it is with copy/paste, or saving history (F3) in one session and reloading ZTW.HST in another (Alt+F10, Read ZTW.HST from disk).
FF removes this limitation by making your file selection input global across all ZTree instances and preserving it indefinitely in the environment.

File name "chunks"

If files are named consistently, it is almost always easy to spot characteristic file name parts ("chunks") that can be used as a group of several key characters to identify the file. FF relies on this a lot. If your media files (music, video, professional documents, photographs, etc.), tend to be named like:
artist_album_song_yyyy
movie_yyyy
yyyymmdd_event_person
yyyymmdd_event_place_person
yyyymmdd_TVprogramme_person
yyyymmdd_TVprogramme_subject
Product_report_month
Project_minutes_date
they are perfect candidates for FF rather than the standard Filter operation. All you need to do is concentrate on the chunks (yyyymmdd, event, song, person, etc.), enter a few key characters per chunk, and hit Shift+Enter. Most of the time, you don't even need to think about file extensions.

Standard filespec
A complete, standard ZTree filespec that uses all three filters (Name, Size, Date) may look like:

*.*x*,-*beta*.txt,about.,ZT*.ZAM,<=s1000,>=s1000000,>=TODAY-1

There are four Name, two Size, and one Date filter part in this example, and ZTree allows even longer queries.

However, in practice, it is unlikely that one will go that far and construct this manually on a regular basis. It's just too impractical. It takes time and concentration to enter and manipulate 61 characters, and users will instinctively stop using this approach and never learn how powerful Filter really is. Although ZTree histories are of great help, if the input is too specific (as in the above case) it may not be a candidate for bookmarking and later reuse.

It would be interesting to know how many ZTree users actually use the Size and Date filters to narrow down the search, but I'd suspect very few. Rather, they concentrate on the Name part and end up with file lists longer than necessary.

The result: Filter is underutilized as the user wastes time scanning the file list, issuing different sorting and Filter commands, scrolling up and down a huge list, hiding files with Shift-Numpad-minus, etc.

Fuzzyspec definition
FF uses a different approach: it encourages the user to think very roughly about what he wants to see based on characteristic chunks that make up file names. Whereas Filter is very precise and indispensable for sensitive file operations and macros, FF is akin to googling your disk for a set of files. This often results in too many hits, but this is inversely proportional to the effort put into formulating the search. Clearly, the more characters you type, the higher the relevance of the hits. But the choice of characters you make (not their number), is often the decisive factor, just the way it is in a search engine.

In practice, FF queries three or four keys long get you what you want. From my experience, it cuts in half (at least) your typing and time spent selecting files.

In addition, FF provides simple tokens for date-based filtering that cannot be done in ZTree (or Explorer) at all. This feature alone justifies installing FF.

FF can generate a filter similar to the above (and give roughly the same result) with just:

.x -bta.t ab. zt.za<3>6:Y

The above fuzzyspec input, if terminated with Shift+Enter, will look like this to ZTree Filter:

*.*x*,-*b*t*a*.*t*,*a*b*.,*z*t*.*z*a*,<=s1000,>=s1000000,>=TODAY-1

In the above example, FF stuffed the four Name parts with asterisks and replaced the two Size and one Date tokens by their long (boring to type in) equivalents. The 26 input characters were expanded into 66. One sees that this is not very different from the hypothetical manually entered command line.

The :Y token above means "since yesterday", and is translated (like everything in FF) into a legal filespec construct, >=TODAY-1. But what if you want to select this week's files only? Simply use the week token, :W (ZTree has no =WEEK keyword yet, but by using the TODAY-n trick, FF recalculates dynamically the start of the week).

Moreover, you'd like to work on this week's files (only) for the rest of the day! FF allows you to set and forget the Date (or Name or Size) criteria and change only the part you want knowing that the other filters will remain in effect. Again, ZTree (and most other tools, probably) cannot help you here, because filtering is not split into classes (Name, Size, Date), like it is in FF.

The N tokens are pre-defined shortcuts for certain lower and upper Size filter reanges. They are essentially strings of the <=s10^N and >=s10^N type (where N is the number of zeros in the number) that the user can customize in the sources. (Actual assignments are shown below.)

FF Tokens and commands
FF tokens are two-character codes expanded into predefined strings by the FF pre-processor. They can be inserted anywhere on the command line, even be embedded in Name chunks! In other words, type them the moment you decide you need them. With FF, there is no need to plan your input in any structured way. You can modify existing, or add new tokens to the lists below in FF.AHK.

To keep tokens and their length consistent, the <N and >N tokens actually mean <=N and >=N, in other words, the '=' is implied. This is similar to ZTree's CO-4J. As a result, '=' can be used as a regular file Name search character.

Filter persistence (stickiness)

A very powerful FF feature is the total independence and persistence of the Name, Size, and Date filters, allowing the user to set and forget criteria that will never change. Somebody working exclusively with log files and similar monitoring data may want to set the "calendar" to the current day (:T) and work in that mode for the entire day, effectively hiding from ZTree's commands any older files.

This separation and persistence of the three filters is the crucial difference between FF and Filter: a filter will only change if explicitly requested by the user!

Fuzzyspec examples

In the examples below, keep in mind the separation and persistence of Name, Size and Date filters. If an example specifies only a Date token, the Name and Size filters are preserved.

  1. To select all *.HTM and *.HTML files from those currently logged, 3 characters should be enough:
    User types: f.htShift+Enter
    ZTree sees: *.*h*t*
    Note that ".tm" is not as good, since it would also match any *.TMP files.
  2. To select all Beatles MP3 tunes from the Help album:
    User types: fbtlhlp.3Shift+Enter
    ZTree sees: *b*t*l*h*l*p*.*3*
    The trick is to pick chunks of characteristic letters that uniquely identify the files. It helps to use naming conventions and know how name chunks are ordered. Note that it is very unlikely to find any other file types containing a '3', other than .MP3, in a typical collection of user files (that is, excluding junk in temporary and some Windows directories). With FF you will discover that, like the name part, the extensions will rarely need to be fully typed in, one or two letters sufficing.
  3. To add to the above search all Kinks tunes, first recall the previous fuzzyspec and append to it more letters:
    User types: f.Shift+Enter
    ZTree sees: btlhlp.3 (recalled fuzzyspec, with cursor at the end)
    User types: {Space}knk.3Shift+Enter
    ZTree sees: *b*t*l*h*l*p*.*3*,*k*n*k*.*3*
    Since ',' is a valid file character, SPACE must be used in FF to separate Name items. When ZTree expands the fuzzyspec, it converts spaces to commas to construct the standard filespec:
    User types: fa,b cShift+Enter
    ZTree sees: *a*,*b*.*,*c*.* (Two filespecs generated)
    User types: fa b cShift+Enter
    ZTree sees: *a*.*,*b*.*,*c*.* (Three filespecs generated)
  4. FF may give too many hits, especially with very long file names. It helps to increase the number of letters, or to suppress a '*' from being inserted between certain letters by using the '/' operator:
    User types: fab/c/d/./zShift+Enter
    ZTree sees: *a*bcd.z*
    If you find yourself typing too many slashes, consider using the standard Filter and asterisks :-). Both FF and the standard Filter usage have their place and can lead to identical results, but if you find typing asterisks (even a single one!) too tedious, FF is your friend.
  5. In a huge collection of media files you want to select those where the word "jazz" appears (but not "cool"):
    User types: fjzz -coolShift+Enter (note the space)
    ZTree sees: *j*z*z*.*,-*c*o*o*l*.* (Note that FF added the ".*" part)
    This example shows how the expanded, verbose, fuzzyspec may sometimes be superior to the standard Filter, because it will catch all variants and typos like: jzz, Jaaazz!, juzz, J_A_Z_Z, j-a-z-z, etc. FF is thus useful as a discovery (and clean up) tool as it lets you see files whose expected names have suffered from somebody's fat fingers or lazyness. You'll often stumble upon files you never knew existed, or have forgotten about.
  6. User types: fab.Shift+Enter
    ZTree sees: *a*b*. (Note that FF added nothing after the dot)
    This allows locating files without an extension. If the '.' is omitted from input ("ab"), the more frequently needed format is generated, "*a*b*.*", as expected from a tool designed to save you time. I maintain an About. text file in many dirs, and this is how I locate them easily.
    Consider using the '.' only when the file extension crosses your mind as something that matters in the situation at hand. Unfortunately, most tools require you to think about and specify the extension, even when it's irrelevant to you. Not FF!
    Again, knowing what files are available, helps you decide whether you want to use the '.' or not. For example, in a list of thousands of MP3's only, there is no point of even thinking about the extension -- just concentrate on song, year, and artist Name chunks and let FF do the work!
  7. Locate all your photos taken in Hong Kong in the last century:
    User types: fhgkg.p:cShift+Enter (Consonants seem to work better than vowels)
    ZTree sees: *h*g*k*g*.*p*,<2000-01-01
    By pure chance, ".p" suffices to cover the most frequently used image formats: .JPG, .JEPG, .PNG, .BMP. You may discover other file extensions in your specific file collections requiring a one-letter "wildcard".
  8. To select files equal to or smaller than 1MB:
    User types: f<6Shift+Enter
    ZTree sees: <=s1000000
  9. Select files equal to or greater than 1MB:
    User types: f>6Shift+Enter
    ZTree sees: >=s1000000
  10. Select all zero-byte files modified today:
    User types: f<0:TShift+Enter
    ZTree sees: "=s0,=TODAY"
    To avoid introducing a new token, such as '=' (which is a valid filespec character), FF uses '<0' in this special case to mean '=s0'.
  11. Detect any files with dates in the future:
    User types: f:FShift+Enter
    ZTree sees: ">TODAY"
    Such files should be suspect, but you may time-stamp them in such a way yourself for some special purpose and be able to locate them instantly.
  12. Select all .ISO, .AVI files (these are usually above 100MB, or 10^8 bytes) from year 2000 (current century) and later:
    User types: f:C.avi >8.isoShift+Enter
    ZTree sees: "*.*a*v*i*,*.*i*s*o*,>=s100000000,>=2000-01-01"
    Note how tokens can be inserted anywhere, in this case, glued to Name parts.
  13. Select all *.LOG non-zero-byte files:
    User types: f>0.logShift+Enter
    ZTree sees: "*.*l*o*g*,>s0"
    Since all filters are sticky, you may keep the ">s0" part constant when working with certain types of files, those which are of no interest if empty. Some log files may act this way until closed. Hitting F3 to refresh the list will reveal them, once they are no longer empty.
  14. Select extremely small and extremely large files:
    User types: f<1>9Shift+Enter
    ZTree sees: "<=s1000,>=s1000000000"

Cycling through ZTree instances

FF has a feature similar to Windows Alt+Escape, but it only cycles through ZTree instances and hides all other active applications from the user. If you run no more than two or three ZTree instances, this approach may make sense to you, try it. It requires three keystrokes and, again, it must be invoked from the Filter dialog: f|Shift+Enter.

Since '|' is a shifted key and usually right above Enter, the three keys are not that hard to type, as Shift needs to be held down for terminating with Shift+Enter. (I actually have a single global hotkey which does this cycling, so I never use f|Shift+Enter. It was added to FF to illustrate the power of AutoHotkey.)

NOTE: FF is a rewrite of EZFF. The latter uses single keys to do more or less what FF does from within the Filter dialog. EZFF is more efficient as there are no such keys as f and Shift+Enter (used to "package" user input) to think about. The trade off is that one needs to learn 6 new hotkeys (and optionally a few more for debugging and fun purposes), and that ZTree is somewhat more "polluted" than with FF's only hotkey, Shift+Enter.

Fuzzyspec maintenance

Because FF keeps the Name, Size and Date filters separate, a filter can be removed (reset) without impacting the other two. In fact, if this is not done explicitly by the user, the filters will remain sticky in FF's memory space even when all ZTree sessions terminate. (But when new ZTree sessions are launched, the fuzzyspec will be waiting to be reused, via f.Shift+Enter! This could be useful when testing a flood of ZTree zetas or other similar situations.)

Technical notes

Disclaimer
The FF executable and sources are free for anybody to use and modify at their own risk.
FF is being used daily with the lastest versions of ZTree on Windows XP/SP3. No tests were done on other platforms.


Copyright 2007-2012 vujnovic@free.fr. All rights reserved.
Updated: 20120802