LastModifiedMillis - Convert Milliseconds to Seconds

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

GA_Forum

Posts: 11
Joined: Mon Nov 10, 2014 3:05 pm

Post by GA_Forum » Wed Mar 15, 2017 12:53 pm
Before I process a paticular file, I want to wait until the file has not been modified for a specific amount of time
(for this example that is 60 seconds). To do this I created a project (see XML below) that does the following...

1.) Creates a file list over the directory where the file resides.
2.) Then I loop through the files in that file list to do the following...
2a.) Print the file attributes to the log file.
2b.) Check to see if the lastModifiedMillis is less than 60,000 (60 seconds). If it is then a while loop is entered and cycled
through until the lastModifiedMillis is greater than 60,000.
-- If lastModifiedMillis < 60000
-- Create variable "LessThan60" to get the number of milliseconds that have past since the file was last modified.
-- Print an informational message to the log file stating that the file is not old enough to move. I wanted to
include the number of seconds (instead of milliseconds) that had past since the file was last modified. I had to
convert the milliseconds to seconds, so I included the variable "LessThan60" and multiplied it by 0.001 ("${LessThan60*0.001}")
in the print task.
-- Delay the project for 30 seconds before cycling through the while loop again (or exiting the while loop).
-- If lastModifiedMillis is not < 60000
-- Create variable "MilliSec" to get the number of milliseconds that have past since the file was last modified.
-- Print an informational message to the log file stating that the file is old enough to process. I wanted to
include the number of seconds (instead of milliseconds) that had past since the file was last modified. I had to
convert the milliseconds to seconds, so I included the variable "MilliSec" and multiplied it by 0.001 ("${MilliSec*0.001}")
in the print task.

So my question is, is there a way to do this without having to create the variables "LessThan60" and "MilliSec"? I tried using
“${CurrentTimeMillis()-thisFile:lastModifiedMillis}*.001” in the print task, but that didn't work, it actually returned the number
of milliseconds and the text "*.001" ("7890*.001"). If something like “${CurrentTimeMillis()-thisFile:lastModifiedMillis}*.001” can
be used in the print task, what is the correct format for that?

XML is below.

Thank you for any suggestions or ideas!
Code: Select all
<project name="Last Mod Example - Convert Millisec to Sec" mainModule="Main" version="2.0">

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

		<createWorkspace version="1.0" />


		<createFileList fileListVariable="fileList" numFilesFoundVariable="fileCount" version="1.0">
			<fileset dir="E:\Program Files\Linoma Software\GoAnywhere\userdata\tcm_temp" />
		</createFileList>

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

			<print label="Print - to log file" version="1.0">
				<![CDATA[============================================================================================================
Attribute List for File ${thisFile:name}
name: ${thisFile:name}
extension: ${thisFile:extension}
last modified date:${thisFile:lastModifiedDate}
last modified Millis:${thisFile:lastModifiedMillis}
size: ${thisFile:size}
path: ${thisFile:path}
nameWithoutExtension: ${thisFile:nameWithoutExtension}
parentFile: ${thisFile:parentFile}
============================================================================================================]]>
			</print>

			<whileLoop label="While Mod Time < 60 Seconds" condition="${CurrentTimeMillis()-thisFile:lastModifiedMillis <60000}">

				<setVariable label="Set Variable - LessThan60" name="LessThan60" value="${CurrentTimeMillis()-thisFile:lastModifiedMillis}" version="2.0" />


				<print label="Print to log file" version="1.0">
					<![CDATA[============================================================================================================
File is not old enough to move. Only ${LessThan60*0.001} seconds difference.
============================================================================================================]]>
				</print>


				<delay label="Delay 30 Seconds" time="30" timeUnit="seconds" version="1.0" />

			</whileLoop>

			<setVariable label="Set Variable - MilliSec" name="MilliSec" value="${CurrentTimeMillis()-thisFile:lastModifiedMillis}" version="2.0" />


			<print label="Print to log file" version="1.0">
				<![CDATA[============================================================================================================
File is old enough to process. ${MilliSec*0.001} seconds have past since the file was last modified.
============================================================================================================]]>
			</print>

		</forEachLoop>
	</module>

	<description>Example project showing how to retrieve the last modified date for a file and also how to verify the last mod time of the file.</description>
</project>
1 post Page 1 of 1