Hello MonahHanks,
The createFileList task uses your operating system to read files in your folder and populate the variable. GoAnywhere Director does not currently have methods that allow you to sort the fileList, but you can create a forLoop and iterate through your fileList in reverse order. The forLoop would replace your forEachLoop and iterate using an index variable.
1. In your
createFileList task, populate the
Number of Files Found Variable field. In my example, I called the variable "numFiles." If your directory contains 8 files, then this variable will be assigned the integer 8.
2. Create a
forLoop. On the
Basic tab, use the ${numFiles} variable as the
Begin Index. Set the
End Index to '1', and set the
Step to '- 1.'
On the
Advanced tab, set the
Current Index Variable to 'index.' The current file variable would now be ${fileList[index]}.
This loop will begin on Index 8 (the number or files in the directory) and decrement by 1 each time it loops, and end on the first file.
Here is an example of a forLoop that gets a list of files, and then prints them out in reverse order:
Code: Select all<project name="File_List_Reverse_Order" mainModule="Main" version="2.0">
<module name="Main">
<createWorkspace version="1.0" />
<createFileList fileListVariable="fileList" numFilesFoundVariable="numFiles" version="1.0">
<fileset dir="C:\TestLoop" recursive="true" />
</createFileList>
<forLoop beginIndex="${numFiles}" endIndex="1" step="-1" currentIndexVariable="index">
<print version="1.0">
<![CDATA[${fileList[index]}]]>
</print>
</forLoop>
</module>
</project>
Please let me know if you have any further questions.