mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2003
Posts: 42
Demarko Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Sep 2003
Posts: 42
Is it possible somehow to strip codes from existing log files?

To strip codes (like bold, underline, colors, ...) from log files you have to go to
Code:
mirc Options
-> Logging
and check
Code:
-> [x] Strip Codes

I know that.

But now I have this little problem:
It seems that this option was not checked before, so now I have like 200 log files from the year 2009.
And I need to remove all the codes from them now, because there are some many bold and color codes that reading those files is really hard.
How can I do that?

Many Thanks in advance. smile

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
You could use the little remote script below.
Having the script loaded, type "/logstrip" to open the file selection prompt.
Code:
alias logstrip {
  noop $$msfile($logdir $+ *.log,Selct file(s) to strip (you may select multiple files))
  if ($msfile(0) > 0) {
    var %fn = 1
    while ($msfile(%fn)) {
      var %lines = $lines($v1), %ln = 1, %in = $qt($v1), %out = $qt($v1 $+ .temp)
      .fopen ls.in %in | .fopen -o ls.out %out
      if ($ferr) {
        .fclose ls.in | .fclose ls.out
        echo -sg * Aborted (Error: $v1 $+ )
        return
      }
      while (%ln <= %lines) {
        .fwrite ls.out $strip($fread(ls.in)) $+ $crlf
        inc %ln
      }
      .fclose ls.in | .fclose ls.out
      .remove %in | .rename %out %in
      inc %fn
    }
    echo -sg * Done (stripped $msfile(0) logfiles)
  }
}

Note that I did not test the script thoroughly - I suggest to backup your original files, or do a "test run" on some copies... smile

Joined: Sep 2003
Posts: 42
Demarko Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Sep 2003
Posts: 42
Super! You saved my day. smile smile

I just did a test run on 3 log files and it worked, the test files look ok at the first view.
Now I only need to verify that they are still "the same" as before, before I do the other hundreds files.
But as its late already, I'll do that another day. sleep

Thank you!


Link Copied to Clipboard