mIRC Homepage
Posted By: Dankirk $findfile() trims whitespaces from filenames - 08/08/09 11:52 PM
Reproduction with following:

Create a file with some whitespaces in its name. use $findfile to find it, for example:
$findfile(,,,echo -a $count($1-,$chr(32)))

This echoes number of spaces in found filename(s).

Running mIRC 6.35 on Vista 32bit.
$findfile is not trimming any spaces, the fact that the file is located in $1- for scripting purposes means it's already been tokenized by spaces and therefore the multiple spaces are lost. This is unfortunately a reality of how parameter tokenization works inside mIRC.

One possibility is that mIRC could stop tokenizing filenames by $chr(32) and use $chr(44) or some other token instead (perhaps an illegal file character), that way the entire file would be contained in $1. Another thing mIRC could do is create a special identifier (like $findfilematch or the \1 in $regsubex).

Until that change is made, you'll have to loop through $findfile(dir,*,%i) to get the accurate filename. You can see that $findfile is not actually trimming spaces because this usage will maintain all spaces.

Example:

Create "test 1 2 3.txt" in your $mircdir and use
//echo -a $count($findfile($mircdir,test*.txt,1), $chr(32))

That said, there's not much you can do with these filenames inside mIRC, the second you use them outside an identifier the extra space will be lost. This basically means you will not be able to perform any file operations on these files (/write, /rename, /remove) except $read.
Use $findfile().shortfn
Thanks for these clarifications and workarounds.
© mIRC Discussion Forums