order of files in filelist

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


Posts: 41
Joined: Wed Mar 30, 2011 10:19 am

Post by monahanks » Tue Nov 05, 2013 1:52 pm
Hi, I have a GoAnywhere project that reads a folder and generates a Filelist variable. The files are named:
(folder path/)PPE 101913 - Week 37.xls and
(folder path/)PPE 102613 - Week 38.xls

When i generate the file list variable, it shows and processes the second (Week 38) file first. does the filelist function populate the list in reverse order (add files to top of stack), and if so is there a way to reverse that?


User avatar
Site Admin
Posts: 47
Joined: Wed Jun 21, 2017 8:12 am

Post by Support_Philip » Tue Nov 05, 2013 3:17 pm
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" />

		<forLoop beginIndex="${numFiles}" endIndex="1" step="-1" currentIndexVariable="index">

			<print version="1.0">


Please let me know if you have any further questions.
Philip Horn
Senior Support Analyst
e. [email protected]
p. 1-800-949-4696
w. GoAnywhere.com | HelpSystems.com
2 posts Page 1 of 1