mIRC Homepage
Posted By: BIGZIPZ Removing spaces in a text file - 24/01/07 02:00 PM
Hey guys, looking forward to your help.

Imagine you have a text file with the following line:

"Song.mp3 6.1MB"

Is there an identifier etc that can read a file and remove everything after Song.mp3, i.e. the spaces and the filename so I am left with a text file full of just Mp3 filenames on each line.


Thanks
Posted By: Vulcan Re: Removing spaces in a text file - 24/01/07 03:00 PM
someone is going to come up with a better solution then this i know it but its worth a shot.

Code:
var %a 1
while (%a <= $lines(file.txt)) {
  .write $+(-l,%a) file.txt $gettok($read(file.txt,%a),1,32)
  inc %a 1
}

Posted By: hixxy Re: Removing spaces in a text file - 24/01/07 08:28 PM
If there are spaces in the filenames in the list you will need a slightly more advanced script than the one vulture offered.

Code:
alias fixfile {
  if (!$isfile($1-)) { 
    echo $color(info) -bfilrt * /fixfile: The file does not exist. 
    return
  }
  var %line = 1
  while ($read($1-,n,%line) != $null) {
    write -l $+ %line $qt($1-) $gettok($v1,1- $+ $findtok($v1,$wildtok($v1,*.mp3,1,32),1,32),32)
    inc %line
  }
}


/fixfile <file>
© mIRC Discussion Forums