coles Posted April 7, 2016 Posted April 7, 2016 What i am trying to do is compare date of destination and source, and if source file is newer than destination it copies the file to source. Just posting a sample code of what i am trying to achieve #include <Date.au3> ; Include Date constants #include <File.au3> #include <iNet.au3> #include <_XMLDomWrapper.au3> Global $xml1, $xml1monthday, $xml1year, $xml1format, $xml2, $xml2monthday, $xml2year, $xml2format, $xmldate ; Runs the XmlDate() function to determine the age of the Xml file ;===================================================================== XmlDate() Func XmlDate() $Xml1 = RegRead("C:\Temp\m1.xml","XmlDate") ; pulls registry $xml1monthday = StringTrimRight($xml1, 5) ; takes the month $xml1year = StringTrimLeft($xml1, 6) ; takes the year out $xml1format = ($xml1monthday & "/" & $xml1year) ; reorders the date $Xml2 = RegRead("C:\Temp\m2.xml","XmlDate") ; pulls registry $xml2monthday = StringTrimRight($xml2, 5) ; takes the month and $xml2year = StringTrimLeft($xml2, 6) ; takes the year out $xml2format = ($xml2monthday & "/" & $xml2year) ; reorders if $Xml1 = "" And $Xml2 = "" Then FileCopy( "C:\temp\a1.txt", "C:\temp\anokh", 1); Else FileDelete("c:\temp\a1/txt") EndIf EndFunc Any comments will be appreciated Thank you
RickB75 Posted April 7, 2016 Posted April 7, 2016 (edited) Have you looked at these functions? They are in the help file. FileGetTime ( "filename" [, option = 0 [, format = 0]] ) FileGetVersion ( "filename" [, "stringname"] ) Or... I just found this one that I've used before. #include <Misc.au3> _VersionCompare ( $sVersion1, $sVersion2 ) Edited April 7, 2016 by RickB75
coles Posted April 7, 2016 Author Posted April 7, 2016 @RickB75 Thank you I think i will use Filegettime if versioncompare has to be used,don't we have to add a version number in files?? i cannot edit existing files.
RickB75 Posted April 7, 2016 Posted April 7, 2016 If you can use FileGetTime, you should be able to use StringCompare ( "string1", "string2" [, casesense = 0] ) to compare the two strings. coles and Autoyt443 2
Autoyt443 Posted April 7, 2016 Posted April 7, 2016 Just now, RickB75 said: If you can use FileGetTime, you should be able to use StringCompare ( "string1", "string2" [, casesense = 0] ) to compare the two strings.
mikell Posted April 7, 2016 Posted April 7, 2016 (edited) #include <FileConstants.au3> If Number(FileGetTime("file1.txt", $FT_CREATED, 1)) > Number(FileGetTime("file2.txt", $FT_CREATED, 1)) Then _ Msgbox(0, "", "file2 is older than file1") Edited April 7, 2016 by mikell coles, maniootek and RickB75 3
coles Posted April 7, 2016 Author Posted April 7, 2016 Thanks @RickB75 @mikell for the replies. @mikell with just 1 line of code you just showed how little i know about Autoit.. Many thanks as it works perfectly
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now