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
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 Specialist
- Posts: 91
- Joined: Thu Mar 05, 2009 3:49 pm
- Location: Ashland, NE USA
-
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.
To retrieve the attributes of a complex variable use the following variable reference syntax.
${variableName:attributeName}
The colon (:) separates the variable from the attribute.
- Support Specialist
- Posts: 91
- Joined: Thu Mar 05, 2009 3:49 pm
- Location: Ashland, NE USA
-
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>
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>
- Support Specialist
- Posts: 66
- Joined: Thu Mar 05, 2009 3:49 pm
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
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