Directory Parsing Script
- Last Updated: November 28, 2024
- 2 minute read
- MOVEit Automation
- Version 2024.1
- Version 2024
- Documentation
With this option, you write a script (or use a vendor-supplied script) to parse a directory listing. Directory parsing scripts are written in VBScript and are configured and edited the same as other MOVEit Automation scripts. Two directory-parsing-specific functions are available:
- sDirListing = MIDirGetListing()
Returns the entire verbatim listing from the FTP or SSH server. This typically contains lines separated by CR and LF (ASCII 13 and 10).
- MIDirAddEntry FilenameToMatch, Date, Size, bIsDir, FilenameForGet, FilenameOriginal
Adds an entry to the FTP or SSH directory listing being parsed.
|
FilenameToMatch |
The filename against which MOVEit Automation matches when doing filename wildcard matches. |
|
Date |
A string that uses one of the accepted date formats. |
|
Size |
File size in bytes. Set this to 0 if the size is unknown. |
|
bIsDir |
Boolean variable. True - the entry is a directory. False - the entry is a file. |
|
FilenameForGet |
Filename to send to the server when requesting a download of the file. Typically the same as FilenameToMatch. Used for FTP servers that run on operating systems with unusual file systems. |
|
FilenameOriginal |
Filename to return as the original filename, in contexts such as the [OrigName] macro. It is usually the same as FilenameToMatch. Used for FTP servers that run on operating systems with unusual file systems. |
Most other MOVEit Automation MIxxx functions are not available in a directory parsing script.
To explain the differences between the three versions of the filename, consider a hypothetical FTP server that allows multiple numbered versions of a file, with the version following the filename in a directory listing. Suppose the directory listing looks like this:
MYFILE.DAT;22 45321 2006-05-06 08:11:56
MYFILE.DAT;21 44090 2006-05-05 17:20:40
README.TXT;3 8192 2005-12-30 21:38:27
In this directory listing, there are two versions of MYFILE.DAT, with version 22 being the more recent.
Ordinarily, the user does not know in advance which numeric version is desired; the user knows only that they want the most recent version, or the next-to-most-recent version, etc. Therefore, it is not recommended to configure a MOVEit Automation source with a filemask that refers to a specific version number.
For the purposes of this FTP server, you can invent a filemask syntax in which the most recent version is referred to as MYFILE.DAT(0), the next most recent version as MYFILE.DAT(-1), etc. However, when transferring the file to the destination, the version number is not relevant, because most destination servers do not recognize file versions. Name the file MYFILE.DAT.
There are three versions of the name:
- The name used in the file mask in the source to select the file. For example, MYFILE.DAT(0)
- The name that MOVEit Automation uses to retreive the file. For example, MYFILE.DAT;22
- The name used in the destination as the Original Name. For example, MYFILE.DAT
So, a script parsing this directory listing would do the equivalent of:
FilenameToMatch = "MYFILE.DAT(0)"
MyDate = "2006-05-06 08:11:56"
MySize = 45321
bIsDir = False
FilenameForGet = "MYFILE.DAT;22"
FilenameOriginal = "MYFILE.DAT"
MIDirAddEntry FilenameToMatch, MyDate, MySize, bIsDir, FilenameForGet, FilenameOriginal
See the Sample Script.