Search This Blog

Friday 17 April 2009

Q&A - Run bwavinfo for detected files


Adam on our Forum asks:


Hi all,

I'll confess I'm no expert on scripting, but I've had a good deal of success in running simple batch files on watched directories, up until now..

I'm trying to run a command 'bwavinfo' via a simple .bat file. For the command to work, it requires an "--info" switch after the bwavinfo command, and before the input/output filenames (i.e. bwavinfo --info in.wav >in.txt). I have a working batch file which will do this outside of watchdirectory using the above script, though when i try and run it via watchdirectory, i'm met with a 'bwavinfo is not reconized as an internal or external command' message.

Here's my WD batch file:

bwavinfo --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

bwavinfo relies on Ruby and Java to run, but has been installed correctly, and works fine via a command prompt. Where am I going wrong?!




bwavinfo --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

May I suggest to you to always use full path-names in batch scripts. Something like this:

"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"N:\%WD_FILE_B%.wav.txt"

That way, the bwainfo program can be found no matter how your PATH is setup.

Also, redirecting to "N:\...."... it looks like N: is a mapped network drive? Remember that these drive-mapping will not work if you run this WD task as a service. It is probably a better way to use the UNC name of the drive-mapping, something like

"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"\\Server\share\%WD_FILE_B%.wav.txt"

Finally, for the Ruby & Java issue, you also need to remember that the environment (among other things the PATH setting) may be different for Windows Services. You could temporarily change the PATH in your batch-script yourself, to work-around this, something like

SET PATH=C:\Program Files\Java\jre1.6.0\bin;%PATH%
SET PATH=C:\Program Files\RoR\Bin;%PATH%
"C:\Program Files\bwa\bwavinfo.exe" --info "%WD_FILE%" >"\\Server\share\%WD_FILE_B%.wav.txt" 

Further reading

All those WD_ variables you can use in your batch files...

Saturday 11 April 2009

Convert TIFF to PDF

A request we often get is a way to convert TIFF files to PDF with WatchDirectory.

While WD does not have a native way to do this, you should be aware that WD's "Automatically Run a Batch File" plugin can do almost anything. If there is a command line tool available, WatchDirectory can "run it".

Anyway, we have found 2 ways to convert TIFF to PDF using command line tools. The batch scripts below should be started by WD's "run a batch file" plugin. It is also a good idea to create a filter so WD will only start the script for TIF and TIFF files.

ImageMagick and Ghostscript

ImageMagick is one of my favorite tools for image manipulation. If a format is not "natively" supported by ImageMagick, it can delegate to other tools. ImageMagick needs Ghostscript for PDF support.

Downloads needed:
ImageMagick, I currently use v6.5.1, available here:
Ghostscript, I currently use v8.6.3, available here:

The ImageMagick/Ghostscript script. Note you don't see any reference to Ghostscript, but it must be installed otherwise the script won't work.

@echo off
rem where is ImageMagick installed???
SET IMADIR=C:\Program Files\ImageMagick-6.5.1-Q16

"%IMADIR%\convert.exe" "%WD_FILE%" "%WD_FILE_D%\%WD_FILE_B%.pdf"

rem if you want to remove the tiff after it has been converted
rem uncomment (remove the "rem") the next line
rem DEL "%WD_FILE%"


Another great tool, I didn't even know it supported command line conversions until Dirk (German language support) told me. You can download Irfanview here.

The Irfanview script:

@echo off
rem where is Irfanview installed???
SET IMADIR=C:\Program Files\irfanview

"%IMADIR%\i_view32.exe" "%WD_FILE%" /convert="%WD_FILE_D%\%WD_FILE_B%.pdf"

rem if you want to remove the tiff after it has been converted
rem uncomment (remove the "rem") the next line
rem DEL "%WD_FILE%"

IrfanView settings

Current releases of IrfanView will prompt you with a little popup window (to preview the PDF). Obviously, you don't want that when you are automating the creation of PDF files.

Just start IrfanView, open a TIFF file and save it as PDF. Next to the "Save As" window, where you enter the pdf filename, is a little window where you should select the "not needed" option. From now on, the script above will not cause those prompts.

Friday 10 April 2009

Q&A - Clear the email queue


Flyinglow on our Forum asks:


I have Watch Directory installed on a Management server. It watches directories on a database server. The database server crashed and had to be rebuilt on a new machine. All the files were copied over via a backup. I went into the Watch Directory jobs and just changed the server name for all the directories it was watching as we recreated the folder structure exactly.

When I started the jobs Watch Directory viewed all the files in the folder as new or changed and started sending out mass emails. I turned off all the jobs to stop it. Now when I turn on the System.Mail job it keeps sending out more messages even though all the other jobs are still turned off.

Is there any way to clear the queue for System.Mail? I already went into all the jobs and turned off the missed events option but I haven't turned any of them back on since I can't start System.Mail without flooding my email server.


When a WatchDirectory task sends email, the email message is only prepared: it is written to a directory monitored by the System.Mail task (the wdPostman program). When System.Mail detects the new message in this directory, it is read and sent.

If, for some reason, you want to clear this email queue, you should remove all files in the following directory:


The directory above is the default location on Windows Vista.
You open the "System.Mail\Out" directory by right-clicking the System.Mail task and select the "Explore ..." menu option. Alternatively, select "Tools -> Explore Task Directory" (this opens C:\ProgramData\watchDirectory) and navigate to the System.Mail\Out sub-folder.

The directory contains files with a wdmail extension. These are the actual email messages waiting to be sent by System.Mail/wdPostman. If you have WatchDirectory tasks that are set to "Combine" email messages, you will also find files with a wdmailcombine extension in this directory. Delete these as well.

Thursday 2 April 2009

Small WatchFTP update


We just released a small update for WatchFTP that fixes an issue for people that use accented characters in file or directory names.

Depending on the actual name, the file did not download. Other filenames with accented characters did download, but if you set the task to remove the FTP file after download, the delete failed.

The new release is available on our English, German and Spanish sites.
Just install this release "on top" of your current install and it will keep your configured tasks and settings.