FTP Script! lesson: using the new features in v3.1

Syncplify.me FTP Script! version: 3.1.0+

FTP Script! v3.1.0.50, released earlier today, comes with a bunch of new features and functions to simplify some tasks related to the management of local files. In fact, it’s not just about transferring files to/from FTP servers… what you do with those files after/before you upload/download them to your local disk also matters!

In earlier versions of FTP Script! the FileCopy function, for example, was very limited. It could copy only one file at a time, and it had no support for wildcard file masks. In v3.1 we greatly improved it, and you can now use it this way:

The third parameter (set to true in the example here above) determines whether the function should overwrite the destination file(s) if it/they already exist.

The new FileMove function is parametrically identical to the FileCopy function, only it moves files instead of copying them. When a file is successfully moved, it will only be present in the destination folder, and won’t be present anymore in the original folder. Here’s a sample code that shows how to use the FileMove function:

A slightly more complex (but majorly useful) addition to v3.1 is the brand new FileEnum function. As the name suggests, this function enumerates (tech jargon for “lists”) all files in a directory, matching certain search criteria that can include wildcards. This function requires an object of type TStringList to hold the results of the search, and features an optional Recursive parameter to specify whether the search should be performed only in the specified directory or its subdirectories should also be included. Here’s an example:

As you can see we have to create the DirList object (of type TStringList) ahead of time, and then pass it to the FileEnum function. The third parameter (set to true in the example above) tells the FileEnum function to include the subfolders of C:\Data in the search.

Once the search is complete, the DirList object will contain a list of strings, each item is the fully qualified file name (including full path) of a file matching the *.xml mask, that was found either in C:\Data or in any of its subdirectories.

Once we’re done working on it, the script is also responsible to free the memory used by the DirList object (see the call to DirList.Free).

Print Friendly, PDF & Email
Bookmark the permalink.

Comments are closed.