Search This Blog

Friday, 8 January 2010

Create a CSV of all WatchDirectory Events

Q&A

Thomas asked if it is possible to have an overview of all events (detected files) from all his tasks. The Task History Viewer only shows you information of one task, it is currently not possible to see detected file information for all tasks on one window.

WatchDirectory stores all event information (detected files) in an SQLite database. Each task has its own history database. This post shows how you can create a CSV (comma separated values) file from the history of all your tasks.

Download the Scripts

Download the example scripts and tools (~0.5MB) and extract them to C:\listEvents. Make sure the "tmp" subdirectory is also created. The scripts write temporary files to this directory.

Configure the Scripts

The download contains 2 scripts:

  • listEvents.bat
    This script extracts the latest XXX events of all tasks
  • listEventsByDate.bat
    This script extracts the events of the last XXX days of all tasks

Please inspect the first few lines of those scripts and change them to reflect where you unzipped the download and the location of WatchDirectory's task directory.

How the Scripts Work

Both scripts enumerate all config files in the task directory and write SQL statements to a temporary file to copy event information to a temporary SQLite database. Once all data is copied, it queries the new database and exports the information to a CSV file. Once complete they start Excel to open the CSV.

Tuesday, 5 January 2010

Use File Viking to resize your pictures

The current File Viking beta doesn't include an Action to resize pictures yet. However, if you configure the Run action, it is easy to write a script to call, for example, ImageMagick to resize pictures you drop on a File Viking basket.

The script can use environment variables so it knows which files were dropped on the basket. The variable %FV_FILE% contains the full path to the file dropped on a basket, %FV_FILE_B% contains the "title" of the file without its extension. Below is the example script.

rem Where did you install ImageMagick (www.imagemagick.org)
SET IMA=C:\Program Files\ImageMagick-6.5.8-Q16

rem Where should resized pictures be stored
SET OUTDIR=F:\Testing\Target

rem call convert, make pictures half their original size. As % is a special character in
rem batch scripts, we need to "double" them.
"%IMA%\Convert.exe" "%FV_FILE%" -resize 50%% "%OUTDIR%\%FV_FILE_B%_50percent.png"

rem call convert again, making pictures fit into a 200x200 rectangle while keeping the
rem correct aspect ratio.
"%IMA%\Convert.exe" "%FV_FILE%" -resize 200x200 "%OUTDIR%\%FV_FILE_B%_200x200.png"

And below you see 2 pictures showing how to configure the basket. First we add a Filter action (new in yesterday's beta) so only pictures are allowed for the piped Run action.

The Run action is configured to run a script called F:\testing\fv_resize.bat, this is the script shown above.

This is just a small example how you can create your own actions for File Viking. If you can imagine it, you can do it.