Log of transferred files

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

intl_sp

Posts: 11
Joined: Wed Oct 01, 2014 8:49 am

Post by intl_sp » Wed Oct 01, 2014 11:02 am
After I connect to a target via one of the protocols and get the files,
Can I write a list of files transferred to a new file along with the total number of files transferred using GoAnyWhere director?

Eventually this file will act as a delivery report and will be sent back to the source via one of the transfer protocols.

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Oct 01, 2014 11:45 am
Yes, this is possible.

This information is available to you in the form of a FILELIST variable. The Number of Files transferred also becomes available to you as well.

On the OUTPUT VARIABLES tab when doing a GET/PUT, there are 3 variables available to create. Source FileList, Destination FileList and Number of files transferred.

Once the files have been retrieved, you can do a FOREACH loop across the Destination FileList Variable created from the FTP|Get. This gives you access to all the file attributes (ie., Name, size, last modified date, extension, etc.) and write that to a CSV, flatfile or even a Database table.

Please review these Tips & Tricks articles from our Forum for further information:

Using FileList via SFTP

Taking Advantage of FileList Variables

HTH!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

intl_sp

Posts: 11
Joined: Wed Oct 01, 2014 8:49 am

Post by intl_sp » Wed Oct 01, 2014 12:13 pm
Rick,
Thanks for the quick reply.
I understood the output variables part,

So far here's what I have.
Code: Select all
copy label="Copy to NW folder" sourceFile="${thisFile:name}" destDir="destination/" whenFileExists="skip" numFilesCopiedVariable="copiedFiles" destinationFilesVariable="destFiles" version="1.0" logLevel="debug" executeOnlyIf="${ FileExists == False }" onError="setVariable:NwErr=1" />

			<if label="Network Error?" condition="${ NwErr gt 0 }">

				<setVariable label="Set: Email_Subject" name="Email_Subject" value="*ERROR* : ${system.project.name} -- FTP File Transfer Error on Destination" version="2.0" />


				<setVariable label="Set: Email_Message" name="Email_Message" value="File Transfer error!${system.carriageReturn}File:  ${ thisFile:name }${system.carriageReturn}Error:${system.carriageReturn}${ system.job.error }" version="2.0" />


				<callModule label="(Module) Send Error Email" module="On Error" version="1.0" />

				<iterateLoop />
			</if>
How can use these variables to write out to a file? What task am I looking for after the above, is it the FileList task? how can use it so that I can create a file containing the information that I want...

Support_Rick

Support Specialist
Posts: 592
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Wed Oct 01, 2014 3:17 pm
This is the info that I was referring to in the links ... try looking through this and see if you can use it to do what you need:
Code: Select all
	<module name="Main">

		<createWorkspace version="1.0" />

		<sftp label="Connect to Server" resourceId="sFTP ResourceID" version="1.0">
			<get label="Get Files" destinationDir="${system.job.workspace}" destinationFilesVariable="locFiles" numFilesDownloadedVariable="NoFiles">
				<fileset dir="/Demos/outbound">
					<wildcardFilter>
						<include pattern="*.csv" />
					</wildcardFilter>
				</fileset>
			</get>
		</sftp>

		<forEachLoop label="Loop through locFiles" itemsVariable="${locFiles}" currentItemVariable="ThisFile">

			<print label="Write File Info to CSV file" file="MyFileList.csv" append="true" version="1.0">
				<![CDATA[${ThisFile:name},${ThisFile:size},${ThisFile:lastModifiedDate}${system.carriageReturn}]]>
			</print>

		</forEachLoop>
	</module>

The idea here is to loop through the FileList and get to the File Information. In this example, I'm looping through the list of files that I pulled back from an SFTP|Get command where I created the ${locFiles} FileList variable.

As I loop through that list, I'm writing out a record to a physical file (MyFileList.csv) and appending the information to that file and creating the .CSV file on the fly.

It should be obvious that I can use the ${NoFiles} variable where ever to get that value.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

intl_sp

Posts: 11
Joined: Wed Oct 01, 2014 8:49 am

Post by intl_sp » Wed Oct 01, 2014 4:17 pm
thanks a lot, that helped!
5 posts Page 1 of 1