Three possible solutions:

  • Replace line 4 of your script by: $findfile(D:\,*.mp3,%t,write -a d:\found.txt)
  • You can use a DLL - you may search here
  • you can start a second mIRC and start the script there (prevents freezing of your actual mIRC)