[UP]

EZFF - Enhanced ZTree File Filtering EZ
Download ezff.zip

EZFF prototypes several functions that I always wanted in ZTree, based on what I implemented about a decade ago in my OpenVMS file manager and find hard to live without. I now have them. I hope some flavor of what it offers will make it into ZTree and EZFF will become obsolete fast :-)

Why EZFF?

ZTree file filtering, as described in section "1.4 FILE Specification Box" of ZTW.HLP, currently handles three types of file properties:

Making full use of ZTree's powerful filtering feature is very hard in practice, even with clever use of Filespec's history and macros. There are simply too many permutations to store, bookmark and pick from, let alone type in. The result is that the user most of the time sees more files than needed, requiring visual selection and tedious Filespec fine-tuning. Likewise, most users probably never venture into constructing complex filters and tapping into the full power of ZTree's file filtering. In a word: Filespec filtering is underutilized because it requires too much work.

EZspec definition

The EZFF puts a wrapper around the Filespec interface that allows modifying the three filters independently, but acting as a unified triple filter or "EZspec":

  1. DateSpec: File date filter controlled by Ctrl+,(Ctrl+COMMA)
  2. SizeSpec: File size filter controlled by Ctrl+.(Ctrl+DOT)
  3. NameSpec: File name filter controlled by Ctrl+/(Ctrl+SLASH)

By packaging the Date and Size filters as cycles of commonly used values (which the user can customize in the script source), arriving at the right combined filter becomes very easy, despite the possibly large number of permutations.

The NameSpec feature also simplifies the boring task of inserting wildcards manually giving the user a chance to use the characters making up a file name more intuitively. Most of the time, 3 or 4 characters suffice to select a set of wanted files without thinking about wildcards or spelling at all. By making the '*' implicit, searching becomes much faster and more interesting.

My annoyance with typing '*' was what motivated me to write EZFF; I now rarely use the standard ZTree Filespec syntax. Think of it as "googling" your file list and then tuning your hits as needed. But, as with web search hits, where we almost always find what we need near the top of the first page, EZFF hits are highly accurate.

This has to be tried for a while to be fully appreciated, and changing certain mental habits will also help.

Safe mode

For more efficiency (or amusement), in "Safe" mode, the newly defined hotkeys will work anywhere in ZTree (F9, Viewer, dialogs, histories), not only in FW or DW. In fact, the user need not invoke (or think in terms of) the Filespec command at all!

The Safe mode trade off is that if you are in the B/S/G view, it will be reset to the File Window by default. This is so because EZFF has no idea what the current ZTree context is and, to play safe, always sends three ESC characters and Enter to make sure ZTree is in the File Window.

Safe mode can be toggled on/off with a single key.

Installation

After downloading and expanding the ZIP file, place EZFF files in your tools area (or in #ZThome) and launch EZFF.EXE in any way you want. You need a single instance of EZFF running, regardless of the number of ZTree instances.

If you want to experiment with the source version (four .AHK files), you must first obtain and install AutoHotkey.

EZFF exposed

When loaded into the AutoHotkey interpreter (or executed), this script's presence will be revealed by a large "H" on a green background in the Systray, where it will just sit and wait.

EZFF About popup The EZFF About popup will then be splashed. It can be closed fast with Enter, but it's recommended to select Help and other options at least once. The About popup can be brought back at any time with Ctrl+F10 while in ZTree, in case you want to check for ZTree, AutoHotkey or EZFF updates, for example. Since I used all of these tools frequently when developing EZFF, I found it practical to reach their respective sites instantly this way.

EZFF Debug popup After that, the Debug popup will appear and float annoyingly on top of ZTree and all other windows! It is therefore recommened to learn the basic hotkeys immediately and toggle this window on/off as needed using Ctrl+0. After you learn the hotkeys that you plan to use, you will forget both of these popups and forget that EZFF exists. It was designed to integrate into ZTree as seamlessly as possible.

When a ZTree instance comes into focus (becomes the foremost window on the desktop), EZFF will start interacting with its keyboard handling in a way that is transparent to the user. This is achieved by looking for the "ZTreeWin" string in the titles of all active windows. For this string to appear in its window title, ZTree must be started with the /ZT command line switch. If not, EZFF will not be able to find and interact with ZTree instances.

The interaction between EZFF and ZTree is as follows: certain keycodes (described later) are trapped (not passed to ZTree) and processed by EZFF. The script then builds a string and sends it to the ZTree input stream, as if typed on the keyboard. This is similar to the ZTree macro mechanism (F12), except that this time the strings are arriving from an external program.

EZFF simply sits and waits for subsequent keyboard input, ignoring all keycodes except those described below. Like many similar tools, EZFF can be terminated by right-clicking on the "H" icon in Systray and selecting "Exit". There may also be options to Pause, Suspend, Reload, or Edit the script, all of which are useful for script developers but not needed for general use.

Keycodes processed by EZFF

Each time one of the hotkeys listed below is struck, EZFF sends a string to ZTree's Filespec dialog (along with some control data):

  1. Ctrl+, "DateSpec" cycling key, controlling file selection based on calendar age:

    1. Today (Tuesday)
    2. Yesterday
    3. Start of Week #08 (Monday)
    4. Start of Month (February, 2007)
    5. Start of Year (2007)
    6. All years *other* than 2007
    7. Only files with dates in the future (>TODAY). These files,
      if any, are also included in display #6, because, by definition, their "illegal" dates are outside the scope of the current year. Such files are rare, but don't be surprised to find them on your disks, and don't hesitate to use them creatively :-).
    8. All

    Ctrl+, instructs EZFF to send ZTree file selection commands 1-8 in circular fashion. For example, hitting this key for the very first time will send spec #1 ("f=TODAY"); spec #5 will send "f>=2007-01-01,<=2007-12-31" (current year), etc.

    This is much more convenient than maintaining a Filespec history of date selection criteria, which, except for the "TODAY" token, requires modification the moment a month or a year changes. It would thus make a lot of sense for Filespec to recognize tokens like "HOUR", "YESTERDAY", "WEEK", "MONTH", "YEAR", and possibly some others.

    Note that ZTree CO1K must be set to the yyyy-mm-dd format, because Ctrl+, is programmed to send DateSpecs in this format. I personally find this format unambiguous and the most logical and use it consistently wherever available. Note that EZFF was not tested with any other date format.

    The week selection assumes the week starts on Monday at 00:00, coinciding with the notion of "working week" in most cultures. So, spec #3 will quickly reveal all the modified files since last Monday; the list should grow longer as we approach Friday and then drop to no files at all Sunday at midnight.

    DateSpec strings change automatically as dates change. Many applications (Outlook, web browser site visit histories, etc.) use the familiar calendar concept to group objects; ZTree now has this as well.

  2. Ctrl+< Resets DateSpec to "All" (same as 8). It shares the same keyboard keycap and works in pair with the previous hotkey.

  3. Ctrl+. "SizeSpec" cycling key, controlling file selection based on size in bytes:

    1. [0,999]
    2. [1000,9999]
    3. [10000,99999]
    4. [100000,999999]
    5. >1000000
    6. All

    Ctrl+. instructs EZFF to send ZTree commands 1-6 in circular fashion. For example, hitting this key for the first time will send spec #1 to ZTree ("f>=s0,<s1000"); spec #5 will send "f>=s1000000" (all files equal to or larger than a megabyte), etc.

    Unlike dynamic DateSpec values, the SizeSpec values are hard-coded in the script and can be modified by the user as desired.

  4. Ctrl+> Resets SizeSpec to "All" (same as #5). It shares the same keyboard keycap and works in pair with the previous hotkey.

  5. Ctrl+/ NameSpec prompt ('*') is appended to ZTree's "Filespec: " prompt, as a remider to the user that, after hitting Enter, the input becomes *i*n*p*u*t*. Implicit wildcarding allows extremely fast file selections with minimal thinking and typing.

  6. Ctrl+? Resets NameSpec to "All" (*.*). It shares the same keyboard keycap and works in pair with the previous hotkey.

  7. Ctrl+1 Invokes ZTree's Filespec prompt with active filespec set to the combined NameSpec+DateSpec+SizeSpec string. The user can then edit the string or simply hit Enter. This allows preserving a particularly interesting EZspec in the history. Normally, EZFF does not leave anything in the history.

  8. Ctrl+6 Safe mode toggle. It forces ZTree into FW mode (via DW) before sending EZspecs. If you are sure that you are already in FW or B/S/G, disable this mode, to preventing DW mode from disrupting your context. As more reliable ways of determining the exact ZTree context become implemented, Safe mode will become obsolete. But even today, you can switch it off and simply pay more attention where you are.

  9. Ctrl+7 Restores default Sort settings by sending ZTree the Alt+S,F12 sequence. This is a somewhat quicker way to tell ZTree to revert to the default Sort setting.

  10. Ctrl+8 Sort order toggle (Ascending/Descending). This makes sense only if Auto-Sort mode is enabled.

  11. Ctrl+9 Auto-Sort mode toggle. When enabled, a filter change forces a re-sort on that filter. For example, if you are cycling through sizes with Ctrl+., sorting will switch to Size sort. If you then switch to Date cycling with Ctrl+,, the file list will be re-sorted by Date. With huge file lists and slower machines, you may want to disable this. Experiments with many thousands of files seem OK.

  12. Ctrl+0 Toggles the Debug popup display. This is most useful when learning EZFF and getting used to the hotkeys. This snapshot shows that ZTree is currently in F9 over FW mode, the three filters that make the "EZspec", and various EZFF options. The last line shows the currently selected dir/file in FW.

  13. Ctrl+F10 Displays the About popup, with its action buttons and numerous links to components linked to EZFF.
    Note that here you can unload the script from memory by hitting "Unload", which is faster than mousing around with icons in the Systray. You may also reload the script, if the "Reload" button is available.

  14. F10 Reloads the script and then displays the About popup. This is useful when heavily editing-running-debugging a script that is already loaded in memory.

Examples of generated EZspecs

EZspecs are designed purely for fast interactive use. If you need to stop and think, or type in more than 5-6 characters, you might as well use the standard Filespec dialog -- you are not ready yet :-).

Warning: EZspecs can return surprising and unpredicatable hits, so it may not be wise to use them in macros (if you find a way of doing it)!

Getting rid of EZspecs

To quickly abandon EZspecs set by the three hotkeys and revert to the *.* default, just use the familiar f,Enter sequence! Remember, all ZTree keys are always available when EZFF is running, even with the Debug popup enabled.

Note that if you then go back to hitting Ctrl+, and Ctrl+., the cycles will continue exactly where they stopped. Cycles have no idea what ZTree session you are in and what is going on in it; they just keep sending their strings in a regular, circular fashion to whomever is there to receive them. Your f,Enter sequence thus did not impact the current EZspec in any way.

To reset all the three filters (or any one of them) that make up the EZspec, use the three reset hotkeys listed above, which are, conveniently, the shifted keys of the filter-generating hotkeys.

Technical details and issues

EZFF faces the delicate problem of knowing which state ZTree is in, that is, is the Filespec: prompt available. This can be solved reasonably well by parsing ZTree's title bar or the ZAAP zbar.dat file. This file knows a lot about the current ZTree state, but parsing it before sending each command is quite costly. For more advanced scripts, this may be the only way to go, but EZFF can be more relaxed. The user may even disable the "Safe" mode with Ctrl+6 and simply make sure visually that ZTree is in FW or DW, both of which accept the Filespec command.

There are no known conflicts with the ZTree UI, since none of the above hotkeys are being used officially. But there is a small possibility for conflict if the user is in a history list *and* there are bookmarks using numbers 0, 1, 6, 7, 8, or 9. If any of the EZFF toggle hotkeys (Ctrl+%) is hit, it will be processed by EZFF, and not fetch the bookmarked history item as expected.

Unlike a ZAAP exectuable, there is no need for the /ZB switch and the issues related to writing to a disk file are avoided.

No other programs are impacted by EZFF's hotkeys, not even ZTW_CFG.EXE. Technically, EZFF works only in a window that belongs to the ConsoleWindowClass class and whose title starts with the "ZTreeWin" string. Therefore, EZFF could also easily interact with ZTW_CFG.EXE by attaching itself to a console window with "ZTW.INI" in the title.

EZFF leaves no traces in the Filespec history, or anywhere else. However, ZTree puts all Filespec input into the history by default, so there is a slight overhead caused when EZFF removes these entries. This problem would go away if ZTree had an option to inhibit the history mechanism on a per-command basis -- when it's terminated with Ctrl+Enter, for example.

At launch time, EZFF actually writes a temporary file to the disk and deletes it immediately. It sends ZTree this string:

{Esc}{Esc}{Esc}xSET #ZThome>%TEMP%\ezff.tmp{Enter}{Esc}

allowing EZFF to find out where #ZThome is pointing to by parsing ezff.tmp. A more elegant way of doing it that will eventually be implemented.

It is important to note that each EZFF hotkey only impacts the part of the EZspec that it is in charge of. For example, the date-cycling part will not impact the size-cycling part of the EZspec, permitting a cumulative action of the two cycles. This means that with just these two hotkeys, 7x5=35 combinations of date/size selections are possible. This flexibility is simply just not practical using the standard Filespec mechanism.

To eliminate the need to hit Enter, or, worse, navigate to some directory while using the cycle hotkeys, set ZTree option CO2Q to Remain and CO2R to No. This will make cycles insensitive to cases where there are no hits in the current view, especially the S/G/B view. You will simply see the "No files match the filespec" message but not lose the DW or FW context.

Power use

The number of hotkeys defined by EZFF seem overwhelming at first, but once you configure EZFF the way you like it, all you will be using 95% of the time will be the cluster made up of these three filtering hotkeys:

Ctrl+, Ctrl+. Ctrl+/ (Ctrl+COMMA Ctrl+DOT Ctrl+SLASH)

Occasionally, you may want to reset one or more filters by simply shifting the preceding hotkeys, resulting in: Ctrl+< Ctrl+> and Ctrl+?. The reset hotkeys simply jump to the end of the cycle, so their action is already present in the three central EZFF hotkeys. This means that you don't even need to remember them but simply keep cycling until you reach the reset value.

A useful hotkey to remember is Ctrl+1, to copy the current EZspec into ZTree's native Filespec prompt for further manipulation.

Disclaimer

The EZFF executable and sources are free for anybody to use and modify at their own risk.
Tests were done only on Windows XP/SP2/SP3.
Only the US keyboard was tested, so the central EZFF hotkeys may not be clustered conveniently on other keyboards.


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