|
|
Joined: Apr 2003
Posts: 61
Babel fish
|
OP
Babel fish
Joined: Apr 2003
Posts: 61 |
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 ?
__________________________ Curiosity killed the cat.
|
|
|
|
Joined: Jun 2003
Posts: 5,024
Hoopy frood
|
Hoopy frood
Joined: Jun 2003
Posts: 5,024 |
/help $strip You can automatically strip log files in mIRC Options: ALT+O > IRC > Logging - Check the box 'Strip codes'. Regards,
Mentality/Chris
|
|
|
|
Joined: Apr 2003
Posts: 61
Babel fish
|
OP
Babel fish
Joined: Apr 2003
Posts: 61 |
I have to strip a file with MANY lines.
__________________________ Curiosity killed the cat.
|
|
|
|
Joined: Dec 2002
Posts: 145
Vogon poet
|
Vogon poet
Joined: Dec 2002
Posts: 145 |
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 *
Last edited by gemeau50; 05/09/04 11:22 AM.
|
|
|
|
Joined: Nov 2003
Posts: 2,327
Hoopy frood
|
Hoopy frood
Joined: Nov 2003
Posts: 2,327 |
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.
New username: hixxy
|
|
|
|
Joined: Aug 2004
Posts: 101
Vogon poet
|
Vogon poet
Joined: Aug 2004
Posts: 101 |
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!
Last edited by dr_Eamer; 05/09/04 01:39 PM.
Maybe I wake up one day to notice that all my life was just a dream!
|
|
|
|
Joined: Aug 2003
Posts: 314
Fjord artisan
|
Fjord artisan
Joined: Aug 2003
Posts: 314 |
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-) }
|
|
|
|
Joined: Aug 2004
Posts: 101
Vogon poet
|
Vogon poet
Joined: Aug 2004
Posts: 101 |
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
Maybe I wake up one day to notice that all my life was just a dream!
|
|
|
|
Joined: Dec 2002
Posts: 1,922
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,922 |
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.
|
|
|
|
Joined: Aug 2004
Posts: 101
Vogon poet
|
Vogon poet
Joined: Aug 2004
Posts: 101 |
Cool! Thanx for the info! It's so good to know!
Maybe I wake up one day to notice that all my life was just a dream!
|
|
|
|
|
|