Skip to main content

Introduction to ListFiles Task

Task built to list filed from a directory

R
Written by Riku Virtanen
Updated over a year ago

ListFiles

The ListFiles Task is an especially useful Task which is built to list files from a specific directory via an SFTP connection. The Task can be used for example in a conditional Trigger's Process which lists files transferred to a specific directory. The Task returns a list of file objects which have information on the file.

Input properties

The Task's input properties include all the parameters for the Task to find files in the SFTP server. The first one is Directory. Directory is a necessary parameter; the Task uses it to locate the correct place for where the files should be listed. The directory parameter needs the absolute path to the directory.

The next parameter is File mask. This parameter is optional and can be left empty. An empty File mask parameter means that all the files found in the specific directory will be included to the list. As the name states the File mask can also handle the Task to list files with a specific name, for example with File mask '*.txt' the Task lists only the text files that have the .txt file extension. You can also include part of the file's name in the file mask.

With the next parameter you can choose what the Task is supposed to list. The Include type parameter lets you choose whether the Task is supposed to list files, directories or both from the given directory. This can be helpful if you want to know what a specific directory holds. You can also list files and directories recursively with the parameter Include subdirectories. This will enable the Task to go into those subdirectories and list files in those subdirectories.

Finally, you can choose the encoding used with the file names on the SFTP server. You can either choose from already included encoding formats or choose the other option which enables you to give the encoding format yourself. You can check the possible encodings from here.

Connection properties

The Task's connection properties are very similar to other SFTP Tasks that we handled in the second module. The Task needs the server's address, port number and authentication credentials. The only difference to other SFTP Tasks' connection properties is the lack of the Buffer size parameter. This is not included in the ListFiles Task because the Task is not transferring any data, but rather collects information of the files located in the given directory.

Return properties

The Task returns a Result object which includes two attributes: Count and Files. The Count attribute returns the number of the files found from the directory. The Files attribute is a list of file items which were found from the given directory. The file items in the Files list include a full path to the file, a boolean value for whether the file is a directory and whether the file is a file, length of the file, name, last write time in UTC and in local time and the same with the last access time. This File list can be used with the other SFTP Task but note that the list needs to be mapped in the correct format if it's been used as the filepaths attribute in the DownloadFiles Task.

Did this answer your question?