mIRC Home    About    Download    Register    News    Help

Print Thread
#96739 05/09/04 05:07 AM
Joined: Apr 2003
Posts: 61
G
gaui Offline OP
Babel fish
OP Offline
Babel fish
G
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.
#96740 05/09/04 05:56 AM
Joined: Jun 2003
Posts: 5,024
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Jun 2003
Posts: 5,024
/help $strip smile

You can automatically strip log files in mIRC Options: ALT+O > IRC > Logging - Check the box 'Strip codes'.

Regards,


Mentality/Chris
#96741 05/09/04 06:00 AM
Joined: Apr 2003
Posts: 61
G
gaui Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Apr 2003
Posts: 61
I have to strip a file with MANY lines. smile


__________________________
Curiosity killed the cat.
Joined: Dec 2002
Posts: 145
G
Vogon poet
Offline
Vogon poet
G
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.
#96743 05/09/04 11:10 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
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
#96744 05/09/04 01:37 PM
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
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!
#96745 05/09/04 03:06 PM
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
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-) }

#96746 05/09/04 04:36 PM
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
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!
#96747 07/09/04 02:11 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Quote:
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.

#96748 07/09/04 10:13 AM
Joined: Aug 2004
Posts: 101
D
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
Cool! smile
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!

Link Copied to Clipboard