Page 1 of 1
Returning a File Count from a Monitor
Posted: Mon Jul 17, 2017 10:36 am
by Grodaes
Hello,
As the subject line suggests is there any way to do this? It would be nice to get more information out a file list (or even be able to use it as an array) after it is built. Basically we are looking at monitoring a system but only when it contains a specific number of files do we want to do our SFTP retrieve any chance the monitor can do this without us having to rebuild the list a second time?
Thanks,
Grodaes
Re: Returning a File Count from a Monitor
Posted: Mon Jul 17, 2017 11:11 am
by Support_Tim
Hi Grodaes,
Thanks for your post.
Since the file list variable passed to the project contains a record, or row, for each file in the file list, you an use a For-Each loop in your project to count the files. Unlike the file list variable, there is not a variable passed to the project that contains a count.
The example below is a simple For-Each loop that has an Iteration Variable defined on the Advanced Tab. It just counts the loop.
I created a local file list, but this was just to test. You would be using the monitor's file list.
Example:
Code: Select all
<project name="Count Files in a List" mainModule="Main" version="2.0" logLevel="verbose">
<module name="Main">
<createFileList fileListVariable="fileList" version="1.0">
<fileset dir="C:\Program Files\Linoma Software\GoAnywhere54\userdata" recursive="true">
<wildcardFilter>
<include pattern="*" />
</wildcardFilter>
</fileset>
</createFileList>
<forEachLoop itemsVariable="${fileList}" currentItemVariable="curFile" currentIterationVariable="fileCount" />
<if condition="${fileCount >= 10}">
<callModule label="Process Files" module="Process" version="1.0" />
</if>
</module>
<module name="Process">
<print version="1.0">
<![CDATA[************************************* ${fileCount} files found.]]>
</print>
</module>
</project>
Re: Returning a File Count from a Monitor
Posted: Mon Jul 17, 2017 11:15 am
by Grodaes
Hey! Thanks Tim this will be helpful.