So the current solution I have finds the latest modified FILE inside all of the folders. I need a way to get the latest modified folder. The reason being, a folder will get created on a daily basis, and I will need to use that folder value in a file path so that I can copy the contents of that path in another directory.
The code I have is as follows:
<target name = "latest">
<copy todir = "H:\New">
<last>
<sort>
<date xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
<filseset dir ="H:\test"/>
</sort>
</last>
</copy>
</target>
Folder Overview
Main
|---Folder2(16/01/15)
|---Folder1(28/01/15)
The program needs to select Folder1 (overall idea).
I.E. of file path: C:/A/${latest.modified<}/etc/files
To find a directory rather than a file, use a <dirset> instead of a <fileset>, for example:
<last id="last.dir">
<sort>
<dirset dir="H:\test" includes="*" />
<date />
</sort>
</last>
<echo message="${ant.refid:last.dir}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With