I've got this log file with all these color codes (bold, underline, color).
Is there a way I can strip all these codes without doing replace on all ?
/help $strip You can automatically strip log files in mIRC Options:
ALT+O >
IRC >
Logging - Check the box 'Strip codes'.
Regards,
I have to strip a file with MANY lines.
Message effacé par gemeau50
Sorry that I erased my message, I didn't notice that there was a reply to it.
The command I was refering to and didn't work was:
/filter -ffb infile outfile *
The keyword there is matching, so if you used "hello" as the matchtext, it would find hello regardless of how many control codes were around it.
Here's how I would do it:
alias stripfile { filter -fk $$1 _stripfile * | .copy -o stripfile.tmp $1 | .remove stripfile.tmp }
alias -l _stripfile { write stripfile.tmp $strip($1) }
Usage:
/stripfile file
eg. /stripfile mylog.txt
Warning: This will overwrite the old file.
Note that there is a mIRC option to strip off color codes while logging:
Alt-O -> IRC -> Logging -> Strip Codes (checkbox, 3rd on the left)
Edit: That's a cool feature suggestion! A filter switch that strips codes in output!
Good idea, though if the file has control codes on every single line, or the majority of lines, I'd use file handling commands rather than /write for speed. But if the control codes aren't so abundant then it's possible to only filter the necessary lines:
/filter -nfkg file myalias /[[:cntrl:]]/
alias myalias { tokenize 32 $1 | write -l $+ $1 file $strip($2-) }
Cool!
File handling would surely be faster, but then again how many times would someone need to run this? I just preffered the simpler, faster-written code against the more complicated but faster-executed code.
Also, I didn't know you could edit the file while filtering it. I guess I was too lazy to try it and check it out for myself...
I didn't know about the :cntrl: class either...
Thanx
Also, I didn't know you could edit the file while filtering it.
The truth is that the lines are not being played to the -k alias "on the fly." Instead, they are copied into a separate buffer from which you start receiving them only after the input file (or window) is released. More on this
here.