| View previous topic :: View next topic |
| Author |
Message |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Sun Aug 19, 2012 12:20 am Post subject: Count number of lines |
|
|
hello, looking for a script then when typing !count filename it will count the number of lines of the filename (the file will be in scripts/ folder)
i.e.
!count Work.txt
<Bot> there are 14 lines in scripts\work.txt |
|
| Back to top |
|
 |
doggo Halfop
Joined: 05 Jan 2010 Posts: 97
|
Posted: Mon Aug 20, 2012 5:00 pm Post subject: |
|
|
give this a try, not tested but should do the trick
| Code: | bind pub -|- !count count:numoflines
proc count:numoflines {nick host hand chan text} {
set fname [lindex [split $text] 0]
set loc "scripts"
#check file exists
if {![file exists $loc/$fname]} {
puthelp "PRIVMSG $chan :$loc/$fname does not exist.";return
}
#open file and count the lines
set file [open $loc/$fname "r"]
set nol 0
while {[gets $file line] >= 0} {
incr nol
}
close $file
#msg the channel
putserv "privmsg $chan :there are $nol lines in $loc/$fname"
} |
_________________ NON geeky!! http://gotcode4u.com/ |
|
| Back to top |
|
 |
BigToe Halfop
Joined: 30 Dec 2010 Posts: 99
|
Posted: Tue Aug 21, 2012 4:22 am Post subject: |
|
|
| Works, thank you! |
|
| Back to top |
|
 |
|