Search This Blog

Friday 31 October 2008

Automatically split PDF into separate pages

Split PDF into separate pages

In a previous post I showed how to add a header page to a PDF using Pdftk. This example uses the same program to split a PDF into separate pages. See the previous post for Pdftk download info.

The previous post only mentioned WatchDirectory, but you can obviously also use WatchFTP's Batch File Action to do the same thing.

The Batch Script

Use the following batch script to let Pdftk automatically split the newly detected PDF.

If you want to use this script with WatchFTP, to automatically split downloaded PDF's into separate pages, you need to change some variable names in the script.
All variables that start with WD_ must be changed to WF_, for example %WD_REASON% in the script below must be changed to %WF_REASON%.

(The script does not show properly in some blog-readers, please copy it from the original post)

Make sure to properly configure the script in the first few lines (the variables PD and OUTDIR). You probably want to make sure the OUTDIR variable is not set to the directory your WatchDirectory task is monitoring. If it *is* set to that directory, WatchDirectory will call your script again (and again) for the split pages.

Thursday 23 October 2008

Undocumented - WatchFTP stops after 10 fails

Please note: the current WatchFTP release (2.2.6, released February 14, 2010) has a new window where you can change the settings mentioned in this blogpost.

FTP Server connections are unreliable

Connections to any internet based services, including FTP servers, are quite unreliable if a program expects to "look at it" 24 hrs a day.

Your PC may be down, your internet connection may be down, the DNS server that translates "" to "208.xx.16.38" may be down, the FTP server software itself may have crashed (or is overloaded).......

So you see, a program such as our WatchFTP that intends to monitor an FTP server 24/7 needs to take care of this problem. It must not just "crash" when a connection or download fails, or should it?

Why the program *SHOULD* crash

I've listed a few reasons above why a connection to the FTP server may fail. I am quite sure there are a few hundred others, most notably: you entered the wrong userid/password for the FTP server. In such cases (wrong password), do you want the program to keep running? Trying again and again to login with the wrong password? Giving you a nice green icon, suggesting everything is OK - no need to look in the logs???
Surely Not! You only want to see the green icon if everything is OK.
Green Icon = No Action Required from you
Red Icon = Something is wrong - You must investigate!

When the program should *NOT* crash

When connection failures are temporary, you want WatchFTP to retry. Most connection problems (not, for example, password problems) will solve themselves after a few seconds and work can continue.

How WatchFTP solves this for "new tasks"

When you create a new task, or change an existing task, the WatchFTP user interface (wfcc.exe) writes a "bit" to the configuration file, telling the runtime component (wfrun.exe) this is an "untrusted" task. A task that has never run successfully before.

The very first run of a "new task"

When you start the new task, and wfrun.exe encounters an internet error, it will look at that "bit". If the bit is set (this is a new/untrusted task), wfrun will write the error to the log and exit. 99.9% of the time, the error will be caused by an invalid setting - you have entered a wrong password?.

If the first run is successful, wfrun will reset the "untrusted" bit, so the next time it connects to your FTP server, wfrun will behave as in the next paragraph.

Next Runs - The task already exists

This task has proved itself. A previous run has connected to your FTP server and downloaded some files. If this task encounters an error it should ignore any error and retry.

Well, almost. Maybe the administrator of the FTP server has changed the permissions (password)? Should WatchFTP try to connect again and again?

Undocumented Settings

(note that these settings are currently not available in the User Interface of WatchFTP. Future versions may change this).

What will happen on connection failures (for existing tasks, not for new tasks), is that wfrun will retry several times (with a delay in-between) to connect to the FTP server and download new/changed files.

The number of times to retry is a setting inside the "config file" (contains all settings of this task - see below). If it is not explicitly set (and remember, the user interface doesn't have an option to set it), it defaults to 10 retries. If it fails 10 times, the task will stop.

Between each retry, the task will pause a while (to give the problem time to resolve itself). This pause is also read from the "config file" and, if not present, defaults to 60 seconds.

The above defaults give your internet/FTP server 10 minutes (10 retries * 60 seconds) to resolve its problems.

Changing the Defaults

Like I said earlier, currently these setting can not be changed using the User Interface of WatchFTP. You need to change the file containing the settings directly. Below, I describe how to change both settings for a task called MyTask.

  • Stop the task.
  • Right-click it - a popup menu opens.
  • In the popup menu, select Explore Task Directory
    (actually, the menu-entry below it showing MyTask as the last part of the path) - Windows Explorer opens inside the directory with log-files of MyTask.
  • This is one directory to deep, select the containing ("higher") directory in explorer
  • In this directory, you will find a file called MyTask.config. This is the file that contains all settings for the MyFile task.
  • Open this file with notepad (not with a rich-text editor like MS-Word)

In notepad, find the line that says


Immediately after (on a new line) it enter those 2 new lines:


so it becomes

... the rest that was here before ...

(If you read this in a blog-reader like Google-reader, the formatting above may be wrong, please see the original post)

The above settings will retry to connect a lot more (123 times, instead of 10 times) and will wait 10 seconds between each retry (instead of the default 60 seconds). This will allow ~20 minutes downtime for your FTP server (123 times * 10 seconds = ~ 20 minutes)

So, if your FTP server if often not reachable for short periods, you will want to set sleepafterfailure to a low value (retry with short intervals).

If your FTP server is sometimes not reachable for long periods, you will want to set sleepafterfailure to a high value (retry with long intervals).

The maximum value for both settings is ~30000. 30,000 retries, 30,000 seconds. Unless I miscalculate, that will give your FTP server ~28 years to recover ;-)

Tuesday 21 October 2008

WatchFTP 1.0.7 released

Automatically Download Files from an FTP server

New in this WatchFTP release

  • The SMTP settings window can now send a Test email.
  • When sending email fails, the error that occurred will be written to the task directory. Previously only the email was saved as an EML file.
  • When a task has sent an email, it will also look for previously failed emails and retry them.
  • Emails now have a proper X-Mailer header set.
  • The Browse-for-FTP-directory window, started by the FTP settings window, did not use the originally entered FTP directory as initial directory.
  • The helpfiles were changed to make them better compatible with Internet Explorer 6.

Upgrade to 1.0.7

If you want to upgrade to the current release (free):

  • Stop all your WatchFTP tasks
  • Exit the WatchFTP Control Center
  • Download the current release
  • Install it in the same directory, "on top" of your current install.

The above steps will ensure you keep your settings and tasks.


Now Also Supports Spanish Language

The new WatchFTP version automatically detects if it is running on a Spanish language operating system. The user-interface, web site and help files are all translated to Spanish.

Spanish language support and forum are available as well.


Monday 13 October 2008

WatchDirectory Customer - Volvo Ocean Race

I was watching the news on television a few days ago, and there was an item about the Volvo Ocean Race. Knowing they are a customer, I asked them how they use WatchDirectory.
Here is Andrew's reply.

I work on a yacht race.. the Volvo Ocean Race, and we have 8 yachts racing currently in our event. The yachts transmit movies and images back to our headquarters, via satellite, whilst they are racing.

These files can arrive at any time, and I use WD for monitoring each yachts inbox, and when a new file arrives it moves the files to an approval queue.

Once the material has been approved, it is moved to another directory, and then WD again takes over and moves the files to FTP boxes, sends them to our picture editor, or passes them to our in-house TV team. All through these stages, I also use WD to trigger email alerts.

Because of the 24/7 nature of the event, WD is ideal.

In all I think I now have 58 WD processes running, and as I think of more things I can do with it, I add more software.

The next time you see the Volvo Ocean Race on television, remember you see WatchDirectory at work ;-)

Saturday 11 October 2008

Create a Feed of your Files

Create RSS Feeds with WatchDirectory and WatchFTP

Here is a tip from one of our customers (Thanks Preben!)

Most (all?) blog software allow you to post new blogs by emailing the post to a special email address. Both WatchFTP and WatchDirectory can send emails for detected changes. Other people "worldwide" can subscribe to this blog and see the detected filenames/files. See "Security/Privacy" below if you do not want everybody (including Google) to see your blog.

This will allow you to create a blog with all "new files" detected. People can subscribe to the blog (or add it to their iGoogle home page) so they stay up-to-date with what is happening inside the monitored directories.

There are a few things you can do with WatchDirectory's Email Task that are not currently possible with WatchFTP's Email Action (see the bottom of this post), but a future WatchFTP release will improve on that.

Email posts to Blogger

(Blogger Specific Help is here)

Once you have created your blog (free on Blogger), go to "Settings -> Email" and enter a Mail-to-Blogger Address. This will create a special email address on the blogger domain that will automatically publish all emails sent to it.

Create (or change) a WatchDirectory or WatchFTP task that sends email to the above email address. The subject of your email will be the subject of your post. Your (picture) attachments will also be published (WatchFTP currently does not support attachments). If you want to use the contents of the detected file inside a WatchDirectory email (WatchFTP does not support this yet) as part of the message sent to blogger, enter
in the message-body of the email.


When you setup a blog on blogger, you can make the blog "private" to just the people you invite to this blog. Go to "Settings -> Permissions" and set the Blog Readers to Only people I choose. This allows you to have only a selected audience for your blog.

Other important settings are found on "Settings -> Basic", if you are concerned about strangers viewing this blog, make sure you set them properly.
Add your blog to our listings?
Let search engines find your blog?

WatchFTP limitations

Currently, WatchFTP's Email Action has the following limitations:

  • Can not send HTML email
    WatchFTP's email are "plain text" only.
  • Can not attach the detected files
  • Can not use the content of the detected file as the email body

The above limitations will be removed in a future WatchFTP release.
The current WatchFTP release can only show the filename(s) inside the email messages sent to blogger.

WatchFTP 1.0.7 beta

monitor ftp sites for new files and download them

We just released a new beta version of our WatchFTP program. This new version has mostly minor fixes/features for its Email action. We hope to release version 1.0.7 about a week from now.

New in WatchFTP v1.0.7

  • The SMTP settings window can now send a Test email.
  • When sending email fails, the error that occurred will be written to the task directory. Previously only the email was saved as an EML file.
  • When a task has sent an email, it will also look for previously failed emails and retry them.
  • Emails now have a proper X-Mailer header set. See below for possible use.
  • The Browse-for-FTP-directory window, started by the FTP settings window, did not use the originally entered FTP directory as initial directory.
  • The helpfiles were changed to make them better compatible with Internet Explorer 6.

Using the X-Mailer header line

This new WatchFTP version will write a special header line in all outgoing emails. This header line looks like this:


(where TASKNAME is replaced by the name of the sending task).
Most email clients can filter incoming messages based on these header lines. This new WatchFTP feature, for example, allows you to sort these email messages into special folders or highlight them in a special way. See the documentation of your email client how to set this up.

Download WatchFTP 1.0.7

Version 1.0.7 has been released.

Install it in the same directory as your current install so it will keep your settings and tasks.

Friday 10 October 2008

An Add-On to an Add-on

A few days ago, we released a new version of WdNotify, see this blogpost. One of our customers wanted a program to send messages to wdNotify from inside his batch scripts. That would allow him to see the progress of long-running batch files.


wdTraySender is a simple command-line program you can start from inside your batch files. It sends a message to wdNotify (if it is running, otherwise no harm is done), and wdNotify will show the message on your desktop. How wdNotify shows the message depends on how you configure wdNotify. Currently wdNotify supports OSD (On Screen Display), Balloon tips and a message window.

wdTraySender has 2 parameters:

  • Task name
  • Message text

The first parameter (Task Name) could be the name of one of your WatchDirectory tasks, however anything will do. The second parameter is the message to send. All further parameters are ignored. Make sure to enclose both parameters in "quotes", especially if they can contain spaces.

Example batch script

@echo off
SET TRAY=C:\Program Files\WatchDirectory\wdTraySender.exe

"%TRAY%" "My Example" "script started"
.... some lengty processing ...
"%TRAY%" "My Example" "script ready"

Download wdTraySender

Important Note: wdTraySender can only send messages to wdNotify version 1.3 or higher. wdNotify 1.3 was released a few days ago. Download the latest wdNotify version.

Download wdTraySender here (~60KB).

Wednesday 8 October 2008

New WatchDirectory release - 4.5.5

We just released WatchDirectory version 4.5.5. This is a free upgrade for all WatchDirectory version 4 customers.
Visit the version history to see what's new.

Upgrade your current version

To upgrade, without losing your settings, please follow these steps:

  • Download the latest WatchDirectory version
  • If you use the free wdNotify program, make sure you download and install the latest wdNotify version as well.
  • Stop all your WatchDirectory tasks, including the System.Mail program (wdPostman - responsible for sending email)
  • Exit the WatchDirectory Control Center
  • Start the installer, make sure you select the same directory to install to (so the new version will see your previous settings and tasks).