Page 1 of 1

FileList and Date check

PostPosted: Thu Oct 12, 2017 12:07 pm
by Dudus
SO... :)

i have a list of txt files now in a ListBox - its okay, but inside of these txt files the first row is a date for example 12.10.2017.
How can I check all of the files if I want to check that the date has expired. For example:

1.txt -> first row inside of text file is: 10.10.2017
2.txt -> first row inside of text file is: 19.10.2017

the result is: We would like to inform you, that the 1.txt is expired! Please check it.

Thank You again!
Dudus

Re: FileList and Date check

PostPosted: Thu Oct 12, 2017 3:18 pm
by Gaev
Dudus:

Take a look at this code ...
Code: Select all
... get count of items in ListBox
ListBoxSize "ListBox3" "[LoopCount]"
... loop through each item
Loop "1" "[LoopCount]" "[LoopPosition]"
   ... get item
   ListBoxGetItem "ListBox3" "[LoopPosition]" "[thisListItem]"
   ... if file exists, read first line
   ... NOTE: You may have to prefix file name with file path
   FileExists "[thisListItem]" "[FileExistsResult]"
   If "[FileExistsResult]" "=" "True"
      FileRead "[thisListItem]" "1" "[thisLine1]"
      ... convert file date
      ... NOTE: Choose different file format if not default
      DateToNum "[thisLine1]" "Default" "[thisFileDate]"
      DateToNum "[DateShort]" "Default" "[DateToday]"
      If "[DateToday] ">" "[thisFiledate]"
         AlertBox "Attention" "File [thisLisItem] expired on [thisLine1]"
      Endif
   Else
      AlertBox "Attention" "File [thisListItem] does not exist"
   Endif
EndLoop

... make adjustments as necessary.

Re: FileList and Date check

PostPosted: Fri Oct 13, 2017 6:28 am
by Dudus
Thank you Gave!

Works great! :) yesss