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.

retrieve file information?

Postby 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.
monahanks
 
Posts: 27
Joined: Wed Mar 30, 2011 10:19 am

Re: retrieve file information?

Postby 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
Software Support
Linoma Software
Support_Julie
Support Specialist
 
Posts: 75
Joined: Thu Mar 05, 2009 3:49 pm
Location: Ashland, NE USA

Re: retrieve file information?

Postby 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?
monahanks
 
Posts: 27
Joined: Wed Mar 30, 2011 10:19 am

Re: retrieve file information?

Postby 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
Software Support
Linoma Software
Support_Julie
Support Specialist
 
Posts: 75
Joined: Thu Mar 05, 2009 3:49 pm
Location: Ashland, NE USA

Re: retrieve file information?

Postby 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?
monahanks
 
Posts: 27
Joined: Wed Mar 30, 2011 10:19 am

Re: retrieve file information?

Postby 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" />
Support_Duane
Support Specialist
 
Posts: 65
Joined: Thu Mar 05, 2009 3:49 pm


Return to Community Forum

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest