Input Processing script
Please note that this script requires Beyond
FTP Version 2.4.05 or above.
This script demonstrates the retrieval of files and their subsequent processing by a program. The key is to assure that each file is processed once and only once. This is accomplished by using intermediate directories, the "Archive" function, and the wild card expansion for "Run" operations.
Download
this script example. |
# First check to see if there is anything to do. Look in the remote
# directory for files.
:IF:
Not
Present
{APTServe}C:\Remote Demo\%LN\*.Txt,1
# We did not find any files. Nothing to do at this time.
:Stop:
:End_If:
# There are files. Transfer these files using the Archive feature.
# This will insure that we do NOT move the same file twice.
:Archive:Source
:From: {APTServe}C:\Remote Demo\%LN\*.Txt
:To: C:\BFTPDemo\Incoming\*.Txt
# Now we wait for all the transfers to complete. Even if some fail,
# we want to process any files that have been received.
# However, we do send a mail message so someone can investigate
# the failure.
:IF:
Not
Check Transfers
CompletedOK
:Alert: Mail = C:\BFTPDemo\XferFailed.Mpf
:End_If:
# Now we pass the files into the database program. Our example
# is a .Bat that simply copies the file. Note the use of the File
# expansion wildcard in the Run statement. Beyond FTP will execute
# the .Bat file for each file that it finds. This allows you to use programs
# that do not do their own file expansion.
| :Run: |
C:\BFTPDEMO\input.bat |
|
,%<C:\BFTPDemo\Incoming\*.Txt> |
|
,C:\BFTPDemo |
# Wait for all the programs to complete. If one fails, we alert the tech
# staff. We proceed with the archive in any event.
:IF:
Not
Check Programs
CompletedOK
:Alert: Mail = C:\BFTPDemo\BatFailed.Mpf
:End_If:
# Archive the input files under the current date
:Rename_File: C:\BFTPDEMO\Incoming\*.Txt
:To: C:\BFTPDEMO\%DM-%M2-%Y2\*.Txt |