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,ខ: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)
}
}