$findfilebydate

By zonirc on Mar 12, 2005

find a file based on the date its being access/created/modified.

Updated version

;Name:$findfilebydate
;Author:zonIRC
;Email:zonirc@email.com
;Description: find a file based on the date its being  access/created/modified.
;Syntax: $findfilebydate(dir<wildcard>,N,switch,<operator>date)
;dir<wildcard> 
;        dir is the path of dir where you want it to find any file. If no directory specified, its will check
;        will check on mirc directory
;        <wildcard> is a filename/wildcard of the filename that you wanna  find
;N is the number of file matched that you wanna find, if you  specified 0 for N then it will return
;the total file found. Larger than 0 will return  the Nth file name.
;example: $mircdir*.ini --> will try to find on mirc directory  any file that lasted with .ini
;NOTE: its will return $null if theres are no Nth found file. For example, if it finds 8 total file that
;matched the date and N being specified as 9 then it will return $null.
;switch can be either one or two or all of this:
;        a = file access date
;        c = file creation date
;        m = file modify date
;NOTE: it will only check the 1st switches for the file that matched the date you specified
;<operator>date
;  <operator> can be one of this:
;      == will find file on that date only
;      != will find file that not on the specified date
;      => will find file after than or same as the date  specified
;      <= will find file which before or same as the date specified
;      < will find file before than the date specified
;      > will find file after than the date specifed
;date must be in a format that mirc supported. To know what format that mirc supported use
;//echo -a $ctime(<date format>)
;if its return something then it was supported.
; NOTE: if you  doesnt specified time on the date then its will take the current time. 
;example: 
;           $findfilebydate($mircdir*.ini,0,c,$+(<=,$date)) return total  file(*.ini) that created before or same as today
;   $findfilebydate($mircdir*.ini,4,c,$+(<=,$date)) return 4th file (*.ini) name that created before or same as today
;   $findfilebydate($mircdir*.ini,0,acm,<=12 Jan 2005) return total file(*.ini) that access/created/modified before or same as 12 January 2005
;           $findfilebydate(*.ini,0,m,&#6017;:11:49 12 jan 2005) return total file(*.ini) that modified before 5:11:49 PM 12 jan 2005
;version:
;1.2 - 14/07/2005
;- Added default directory
;- Edited error message to look more friendly
;- Now using while loop to check and compare file date
;- Now freed the hash table when finishing which before this just deleted it
;- Fixed operator error
;- Added 1 more operator which is !=(not equall to)
;1(updated) - 03/13 08:43am:
;- code being edited now which before this found a bug which will not succesfully check either the file access/created/modified date is before/after/same as the date specified. Now its fully functioning. 
;- still in a way to make $file() [ $+ [ $3time ] ] can work however i think it still worth to publish this one.
;First Released - forget when?? :p
alias findfilebydate {
  ;syntax: $findfilebydate(dir<wildcard>,N,switch,<operator>date)
  var %dir = $iif($nofile($1),$v1,$mircdir), %file = $nopath($1), %echo = echo $colour(info) -ast * $!findfilebydate:, %o = $regex($4,^(==|!=|<=|=>|<|>)),  %d = $iif(%o,$ctime($mid($4,$calc($len($regml(1)) + 1))))
  if (!$isid) $replace(%echo,$,/) Unknown Command
  elseif (!$4) %echo Insufficient Parameter - $!findfilebydate(dir<wildcard>,N,switch,<operator>date)
  elseif (!$isdir(%dir)) %echo Directory not exists - %dir
  elseif ($2 !isnum) %echo Invalid 2nd Parameter - $v1
  elseif ($3 !isletter acm) %echo Invalid Switch - $v1
  elseif (!%d) %echo Invalid Last Parameter - $4
  else { 
    var %x = 1, %y = $findfile(%dir,%file,0,hadd -m ffbd $calc($hget(ffbd,0).item + 1) $1-), %z, %t
    while ($hget(ffbd,%x).data) { 
      var %f = $v1, %s = 1
      while (%s <= $len($3)) {
        var %ft = $file(%f). [ $+ [ $left($3,$v1) $+ time ] ], %o = $regml(1)
        if (%ft %o %d) {
          inc %z
          break
        }
        inc %s
      }
      if (%z == $2) break
      inc %x
    }
    %t = $hget(ffbd,$calc(%x ))
    hfree ffbd
    return $iif($2,%t,%z) 
  }
}

Comments

Sign in to comment.
zonirc   -  Mar 13, 2005

anyway thanx to all that gave a comment and teach me how to edit it thanx all

 Respond  
zonirc   -  Mar 13, 2005

aaaaaaaaaaaa that not correct actually like this c:\\mirc\*.ini

 Respond  
zonirc   -  Mar 13, 2005

well splatted it can search a wildcard file. u just need to use the 1st aprameter like this -->

 Respond  
supergeo   -  Mar 12, 2005

yeah I think it deserves a \"neat rating\"

 Respond  
supergeo   -  Mar 12, 2005

also, you don\'t need to comment the lines in the \"author\'s notes\" section.

 Respond  
supergeo   -  Mar 12, 2005

to the right side there is an \'Edit button\' click on that and edit the code froim there

 Respond  
DarthReven   -  Mar 12, 2005

nice lil addon it could come in handy

 Respond  
Relinsquish   -  Mar 12, 2005

There\'s an \'Edit\' button next to the \'Send Snippet to Clipboard\' button. :)

 Respond  
splatted   -  Mar 12, 2005

I haven\'t tried it, but I look forward to the completed snippet. If it doesn\'t already do so, you may want also to add a custom search for specific file types, such as txt, mpeg etc, which will help narrow down a search

 Respond  
zonirc   -  Mar 12, 2005

sorry guys theres are bugs which i had find after submitting this code here so please ignoring this code since i doesnt knwo how to remove/delete this code here :P

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.