retrieve file information?

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

monahanks

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

Post by monahanks » Tue Jun 21, 2011 10:37 am
Hi, can GoAnywhere be used to retrieve information about a file on a Windows server, such as the last time a file was updated? We have a case where a file sits on a Windows server and always has data in it, but if today's update did not run, the data would be from yesterday. Can I use GA to retrieve the last update time of the file and match that against the current date to see if I want to process the data? This would be similar to the DSPFD command on the AS400, or the DIR command on a windows system to see the date of a file.

Support_Julie

User avatar
Support Specialist
Posts: 91
Joined: Thu Mar 05, 2009 3:49 pm
Location: Ashland, NE USA

Post by Support_Julie » Tue Jun 21, 2011 1:05 pm
The file attribute lastModifiedDate will give you the desired result.

To retrieve the attributes of a complex variable use the following variable reference syntax.

${variableName:attributeName}

The colon (:) separates the variable from the attribute.
Julie Rosenbaum
Sr Support Analyst
e. [email protected]
p. 1.800.949.4696
w. HelpSystems.com

monahanks

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

Post by monahanks » Tue Jun 21, 2011 1:40 pm
Hi Julie, I'm not sure where I would use this variable reference syntax you mention, and I'm not finding anything in the Webhelp. Can you point me in the right direction or show me a code snippet of how it is used?

Support_Julie

User avatar
Support Specialist
Posts: 91
Joined: Thu Mar 05, 2009 3:49 pm
Location: Ashland, NE USA

Post by Support_Julie » Tue Jun 21, 2011 4:16 pm
Below I have attached a small sample project that retreives a file list & then prints out the file attributes.
If you so desired, you could Set a Variable to check a condition later.


<project name="Print FileList attribute variables" mainModule="Main" version="1.0">

<module name="Main" logLevel="debug">

<createFileList fileListVariable="fileList" numFilesFoundVariable="fileCount" version="1.0">
<fileset dir="/temp/mltmbr" />
</createFileList>

<forEachLoop itemsVariable="${fileList}" currentItemVariable="thisFile">

<setVariable label="fill trimFileName" name="trimFileName" value="${thisFile:path}" version="1.0" />


<setVariable label="fill mbrName" name="mbrName" value="${thisFile:nameWithoutExtension}" version="1.0" />


<print version="1.0">
<![CDATA[Attribute List
name: ${thisFile:name}
extension: ${thisFile:extension}
last modified date:${thisFile:lastModifiedDate}
size: ${thisFile:size}
path: ${thisFile:path}
nameWithoutExtension: ${thisFile:nameWithoutExtension}
parentFile: ${thisFile:parentFile}
]]>
</print>

</forEachLoop>
</module>

<variable name="libName" value="mylib" />
</project>
Julie Rosenbaum
Sr Support Analyst
e. [email protected]
p. 1.800.949.4696
w. HelpSystems.com

monahanks

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

Post by monahanks » Wed Jun 22, 2011 6:42 am
Thanks Julie. Now, one more question: can I substring (or extract) just the date portion of the lastModifiedDate and compare it to the system current date?

Support_Duane

Support Specialist
Posts: 66
Joined: Thu Mar 05, 2009 3:49 pm

Post by Support_Duane » Mon Jun 27, 2011 11:18 am
Use the print statement to write the last changed date out to a file, then read it in as a delimited file using a space as the delimiter. You then have to do a set variable version 1.0 task to get the date out of the rowset. It will be in yyyy-MM-dd format. If you don’t want the dashes, you can do a search and replace on the file before you do the read CSV.

Here are the XML lines without a search and replace
Code: Select all
	<print label="write date to file" file="date.csv" append="false" version="1.0">
		<![CDATA[${thisFile:lastModifiedDate}]]>
	</print>
	<readCSV inputFile="date.csv" outputRowSetVariable="data" fieldDelimiter="space" skipFirstRow="false" recordDelimiter="LF" textQualifier="none" version="1.0" />
	<setVariable name="date" value="${data[1]}" version="1.0" />
6 posts Page 1 of 1