Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Newest File

$
0
0
Hi Everyone,

i've just startet to script with AutoIT and im not realy used in the syntax of it too :(

I would like to "detect" the newest file in a spezific folder, take it and rename it (filemove) with a value i discript before..

by google i found a function from another user. I think this function is exactly doing what i want.. but i dont get, how i could get the value (variable?) out of the function and use be able to use it..

Here you can see my Script:


[ autoit ]         
Func EvaluateFiles($Folder) $avFiles = _FileListToArray($Folder & "\", "*",1) If @Error<>0 Then Return EndIf $iNewestTime = 11111111111111; YYYYMMDDhhmmss $iNewestIndex = 0; Array index of newest file ; Find the newest file For $p = 1 To $avFiles[0] $iFileTime2 = Number(FileGetTime($Folder & "\" & $avFiles[$p], 0, 1)) If $iFileTime2 > $iNewestTime Then $iNewestTime = $iFileTime2 $iNewestIndex = $p EndIf Next If $iNewestIndex > 0 Then $t = FileGetTime($Folder & "\" & $avFiles[$iNewestIndex]) $iDateCalc = _DateDiff( 'd',$t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5],_NowCalc()) If $iDateCalc > 0 Then;<---Flags files that are older than today MsgBox(16,"ATTENTION","This files in - " & $Folder & " - have not been updated today." & @CRLF & @CRLF & $avFiles[$iNewestIndex] & " is the newest file with a modified date of" & @CRLF & @CRLF & $t[1] & "/" & $t[2] & "/" & $t[0] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]) EndIf Else MsgBox(16, "Error", "Failed to find a newest file.") EndIf EndFunc $date1 = StringRight(@YEAR, 2) $date9 = $date1 & @MON & @MDAY & @HOUR & @MIN & @SEC $Fileformat1 = "ENG"&$date9&"C0Q002001" $Fileformat2 = "ENG"&$date9&"C0Q002002" $file = ("C:\Users\sx40211\desktop\Vorhanden\"&$Folder&".xlsx") $file2 = ("C:\Users\sx40211\desktop\Vorhanden\Neue Datei\"&$Fileformat1&".xlsx") FileMove($file, $file2, 1)

Realy? i dont get it ^^

im sure, that i have to call the function, to get a value.. Call("EvaluateFiles") right?
But how could i get now the name of the newest file?

Please help me anyone... my head is exploding :(

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>