Sample scripts
File Watcher runs the Action command when a file arrives. The Action command can take a number of forms:
Note: the complete path to the command must be specified. Batch Files.BAT files are run via the command interpreter CMD.EXE (formerly COMMAND.COM). Specify the full path to the batch file in the Command field, and the parameters in the Parameters field. Sample .BAT files are included in the FileWatcher install folder. To...Copy each file to a new locationCommand: <complete path\>copy.batParameters: %FILE% Create a batch file called copy.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro rem copy each file to a new location copy "%1" "c:\location1" Note: to retain the original folder structure, use the DOS xcopy command instead of copy in the batch file. To...Copy one file to multiple locationsCommand: <complete path\>copy_multiple.bat Parameters: %FILE% Create a batch file called copy_multiple.bat, and copy the text below into it: @echo off To...Show the name of the file being processedCommand: <complete path\>echo.bat Parameters: %FILE% Create a batch file called echo.bat, and copy the text below into it: @echo off echo File %1 has arrived and is ready for processing To...Log the file being processedCommand: <complete path\>log.bat Parameters: %FILE% Create a batch file called log.bat, and copy the text below into it: @echo off To...Show a list of files being processed as one group � all on the one command lineCommand: <complete path\>echoparams.bat Parameters: %FILE% Create a batch file called echoparams.bat, and copy the text below into it: @echo off To...Show a list of files being processed as one groupCommand: <complete path\>echolist.bat Parameters: %FILE% Create a batch file called echolist.bat, and copy the text below into it: @echo off echo List file is %1 echo Used with FileWatcher's command line and the %FILE% macro echo --[Contents]------------------------ type "%1" echo --[End]------------------------ pause To...Move each file to a new folderCommand: <complete path\>move.bat Parameters: %FILE% Create a batch file called move.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro rem Move an incoming file move "%1" "c:\location1" To...Play a sound when a file arrivesCommand: <complete path\>play_sound.bat Parameters: %FILE% Create a batch file called play_sound.bat, and copy the text below into it: @echo off start sound.wav To...Print each fileCommand: <complete path\>print.bat Parameters: %FILE% Create a batch file called print.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro echo Printing %1 print %1 echo Complete To...View (display) each fileCommand: <complete path\>view.bat Parameters: %FILE% Create a batch file called view.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro echo Viewing %1 start %1 echo Complete To...Send email with file as attachmentCommand: <complete path\>sendmail.bat Parameters: %FILE% You need to download a command line sendmail program � try https://www.downloadpipe.com/business/review-absoluteTools-SendMail-CMD-Single-computer-license-42668ToolsSendMa-1176122.html Note: free versions of sendmail.exe on the web often have viruses and other malware.
Create a batch file called sendmail.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro rem Send mail with this file as the attachment rem rem You need to make sure that sendmail.exe is on your system - test this with rem sendmail -subject='Test message' yourname@yourdomain.com sendmail -subject='File arrived %1' -attach='%1' yourname@yourdomain.com To...Schedule a job if a file arrivesCommand: <complete path\>schedule.bat Parameters: %FILE% Create a batch file called schedule.bat, and copy the text below into it: @echo off rem Used with FileWatcher's command line and the %FILE% macro rem Schedule a process with the file that arrives rem The Schedule service must be running to use the AT command. at 1730 /interactive "echo %1" echo Scheduling Complete DOS CommandsNote that the Windows �start� command is a feature of CMD.EXE. To make use of it, you need to create a batch file that uses �start�. To...Send an EmailTo send an email from File Watcher, you need to use a command-line email program - we recommend FREE blat.net (syntax). We strongly suggest you do NOT search for a free download of sendmail.exe - these are 99% guaranteed to contain a virus. Command: <complete path\> Parameters:
Or even send the newly-arrived file to you: Command: <complete path\> Parameters:
|