Skip to end of metadata
Go to start of metadata

Introduction

This is the fourth in a series of articles describing how to get started with using the the YADE Client via its Command Line Interface and covers:

YADE Tutorials List

YADE Client Command Line Interface

  1. Getting Started and Downloading files
  2. Simple File Selection
  3. More Advanced File Selection
  4. File Transfer

  5. Checking files for completeness
  6. Public / Private Key Authentication
  7. Transfer via a Jump Host / DMZ

Prerequisites

See the Using the tutorials with the YADE Client Command Line Interface article for guidelines to setting up and running the tutorial examples.

Instructions for installing, configuring and using the XML Editor can be found in the XML Editor series of articles.

Download file

The configuration described in this tutorial can be downloaded and then directly opened in the XML Editor using the following link:

Renaming files

The following example combines two renaming possibilities:

  • Renaming files
  • Adding a date-stamp to file names

See the YADE Parameter Reference - Rename article for a full list of the renaming possibilities.

Example

The example assumes that five test_*.txt files have previously been downloaded to the local ${USERPROFILE}\jade_demo\a directory before the example is run. Such a download can be carried out using the simple YADE file transfer operation described in The YADE Client Command Line Interface - Tutorial 1 - Getting Started.

The file name part(s) to be replaced is/are defined in the Replacing parameter with round brackets () and the new part(s) in the Replacement parameter, separated by semi-colons.

The example shows a two-part substitution:

  • test will be replaced with file_ and
  • '_' with the current date in the format specified.

Configuration structure

ProtocolFragment

ProtocolFragments are not specified in this configuration as both source and target are on the local file system. This has been done to allow write permissions at both source and target.

Profile

The meaning of the three elements required to specify renaming - Rename, ReplaceWhat and ReplaceWith elements should be self-explanatory.

Note that
  • the Rename operation in this example described here is specified for the transfer source, meaning that the source files will be renamed and that the files copied to the target will not be. It is also possible to specify Rename for the transfer target, in which case the source files will remain unchanged for a copy operation.
  • write permissions are required before names of files on a file system can be changed.

XML Editor Configuration

The Profile Code

The following code boxes can be opened to show the Profile used in this example in XML and in settings.ini formats.

'local_2_local_replace_datestamp' Profile in XML Format  Expand source
'local_2_local_replace_datestamp' Profile in settings.ini Format  Expand source

Running the Profile

This profile is called on Windows systems using the following command, depending on the YADE version being used:

Running the file transfer configuration in Windows format using an XML (JADE 1.11 and later) or settings.ini file (YADE 1.10 and earlier)

On Unix systems the profile is called using one of the following commands, again depending on the YADE version being used:

Running the file transfer configuration in Unix format using an XML (JADE 1.11 and later) or settings.ini file (YADE 1.10 and earlier)

Behavior

  • The five test_*.txt files in the the a folder will be copied to the b folder under their original names. The source files will then be renamed as described above.
  • If a file is found but not transferred - because for example it has zero bytes and TransferZeroByteFiles is set to false then the file name will remain unchanged.

File cumulation

YADE can cumulate the contents of individual files to a single target file:

  • Files matching the FileSpec regular expression are cumulated together into a new file.
  • The CumulativeFileDelete element is used to specify whether an already existing CumulativeFile is deleted and a new, empty, CumulativeFile created before the content of the individual files being transferred is added to this file. (The CumulativeFile is by default opened in append mode.)
  • The individual, original files can be deleted if required in a Move operation or separate Remove operation.
  • There is not a de-cumulate parameter available at the moment.

Example

The example assumes that five test_*.txt files have previously been downloaded to the local ${USERPROFILE}\jade_demo\a directory before the example is run.

In the example, the contents of these five files written to a CumulativeFile in the local ${USERPROFILE}\jade_demo\b directory. The content of each file being transferred is added successively to the CumulativeFile in the order in which the files are received. This order cannot be controlled during the file transfer operation.

The CumulativeFile is given the name specified in the CumulativeFileName parameter in the profile.

The text specified in the CumulativeFileSeparator parameter is incorporated in the CumulativeFile between the contents of the individual files.

Configuration structure

ProtocolFragment

ProtocolFragments are not specified in this configuration as both source and target are on the local file system. This has been done to allow write permissions at both source and target.

Profile

The three CumulateFile elements are child elements of the TargetFileOptions element as can be seen in the screenshot below.

Note that
  • if the Rename operation is specified for the transfer source, then the source files will be renamed and the files copied to the target will not be. It is also possible to specify Rename for the transfer target, in which case the source files will remain unchanged for a Copy operation.
  • write permissions are required before names of files on a file system can be changed.

XML Editor Configuration

The Profile Code

The following code boxes can be opened to show the Profile and ProtocolFragments used in this example in XML and in settings.ini formats.

The 'ftp_server_2_local_poll_minfiles' Profile in XML Format  Expand source
The 'ftp_server_2_local_poll_minfiles' Profile in settings.ini Format  Expand source

Running the Profile

This profile is called on Windows systems using the following command, depending on the YADE version being used:

Running the file transfer configuration in Windows format using an XML (JADE 1.11 and later) or settings.ini file (YADE 1.10 and earlier)
Running the file transfer configuration in Unix format using an XML (JADE 1.11 and later) or settings.ini file (YADE 1.10 and earlier)

Behavior

Opening the cumulative file text-files.txt in a text editor after transfer has been completed will show the content of all five individual files.

Note that the order of arrival of files in the target system determines the order in which they are added to the cumulative file.

Setting the CumulativeFileDelete parameter to false and running the transfer operation a number of times will show the that this setting allows the ongoing addition of content to the CumulativeFile - a procedure that is commonly used, for example, for log files.