Every time you remove a file and inc the file-count %x, $findfile(dir,N) will not point at the next file but the file
after the next file. The next file would be the file with the
same number, as the "current" file with this number had been removed
To fix this, e.g. change your while loop to inc the number
only if your (file != something)-condition is
not met and the file has
not been removed.
alias cut.files {
var %x = 1
while ($findfile($mircdir,test*,%x,1)) {
var %file = $qt($v1)
if (%file != $qt($+($mircdir,testing.txt))) {
copy -o %file $+($scriptdir,$nopath(%file))
remove %file
}
else { inc %x }
}
}
Edit: Note that - now - this should pass all files correctly if you
execute the copy/remove command, but will result in an infinite loop if you
echo the command only.