Returning a File Count from a Monitor

Post any question you may have in regards to GoAnywhere MFT and let our talented support staff and other users assist you.
3 posts Page 1 of 1

Grodaes

Posts: 10
Joined: Mon Dec 05, 2016 12:12 pm

Post by Grodaes » Mon Jul 17, 2017 10:36 am
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

Support_Tim

Posts: 33
Joined: Mon Dec 01, 2014 10:35 am

Post by Support_Tim » Mon Jul 17, 2017 11:11 am
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>


Grodaes

Posts: 10
Joined: Mon Dec 05, 2016 12:12 pm

Post by Grodaes » Mon Jul 17, 2017 11:15 am
Hey! Thanks Tim this will be helpful.
3 posts Page 1 of 1