File_List Command
Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
3 posts
Page 1 of 1
We have various projects setup which send an e-mail to numerous recipients after moving a file or set of files, depending on the exact project, which reports the name of the files that have been moved. A few different methods for doing this have been experimented with.
Initially we were using a variable along the lines of ${This_File}, which displayed the full file path (something we do not want) until we started adding the :name attribute.
Am I missing something simple here to give one or both of these commands a wild card? Or is there some better method of using File_List so that it will list all of the files within the list without their path?
Initially we were using a variable along the lines of ${This_File}, which displayed the full file path (something we do not want) until we started adding the :name attribute.
Code: Select all
However, this method felt clumsy because it required a duplicate variable entry for every file that would be reported as it would only list the files directly referenced.
We have moved ${This_file[1]:name}
Code: Select all
So I started trying to use File_List to do this instead, which worked perfectly for the basic process and simplified things a bit, but again displayed the full file path. So I attempted adding the :name attribute here as well, but File_List seems to act the same as This_File when :name is added, and it displays the first file within the list when you do ${File_List[1]:name}We have moved ${This_file[1]:name} ${This_file[2]:name} ${This_file[3]:name}
Am I missing something simple here to give one or both of these commands a wild card? Or is there some better method of using File_List so that it will list all of the files within the list without their path?
- Support Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
Can you post an example of what you want to see when the Project is run?
If you're wanting to see a "list" of files moved in the email without the file path, then you will have to create a Variable and loop through the FileList appending the name of the file ${File:name} to the variable, then printing the list at the end.
If there are any questions, please feel free to let us know.
-Rick
If you're wanting to see a "list" of files moved in the email without the file path, then you will have to create a Variable and loop through the FileList appending the name of the file ${File:name} to the variable, then printing the list at the end.
Code: Select all
This could be done with the following code: These files have been Moved by GoAnywhere
File1.txt
File2.csv
File3.xml
Code: Select all
*NOTE* ${ MyDir } is a Variable set to the Directory you want to get the File List from. ${ CutOffDate } is used in this example for identifying a specific group of Files within ${ MyDir }<createFileList label="Get FileList" fileListVariable="Files" numFilesFoundVariable="NoFiles" version="1.0">
<fileset dir="${ MyDIR }" recursive="true">
<dateFilter>
<include to="${ CutOffDate }" />
</dateFilter>
</fileset>
</createFileList>
<setVariable label="Init FileList" name="FileList" value="${ system.emptyString }" version="1.0" />
<forEachLoop label="List Files" itemsVariable="${Files}" currentItemVariable="ThisFile">
<setVariable label="Update FileList" name="FileList" value="${ FileList }${ system.carriageReturn }${ ThisFile:name }" version="1.0" />
<move label="Move Doc" sourceFile="${ ThisFile }" destDir="${ NewDIR }" whenFileExists="overwrite" version="1.0" />
</forEachLoop>
<sendEmail label="Send Notification" resourceId="MyResource" toList="[email protected]" version="2.0">
<from address="[email protected]" />
<subject>
<![CDATA[ These files have been Moved by GoAnywhere ]]>
</subject>
<message>
<![CDATA[ ${ FileList } ]]>
</message>
</sendEmail>
If there are any questions, please feel free to let us know.
-Rick
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Greatly appreciated sir. This part in particular was precisely what I was trying to do.
Code: Select all
<createFileList fileListVariable="fileList" numFilesFoundVariable="listCount" version="1.0">
<fileset dir="myDIR" />
</createFileList>
<setVariable name="sourceList" value="${system.emptyString}" version="2.0" />
<forEachLoop itemsVariable="${fileList}" currentItemVariable="thisFile">
<setVariable name="sourceList" value="${sourceList}${system.carriageReturn}${ThisFile:name} " version="2.0" />
</forEachLoop>
3 posts
Page 1 of 1