Topic: Problem with ruby code calling itself and failing.

Hey, I'm rather new at programming, and ruby, and need some help doing something that is probably quite basic.  If it matters, this is RGSS type ruby, which AFAIK just throws errors differently from regular ruby, aside from that, its the same.

First off, let me show you the code.

rescue Errno::ENOENT #If file isn't found, it loads it from another directory
  p $!.to_s  #Alerts that this script is running
  filename = $!.message.sub("No such file or directory - ", "")  #figures out the file from the error called
  $dest = "D:/Project3/" + filename
  slashes = $dest.count "/"
  loop do # Truncates the end of the string at the slash
    $dest = $dest.chop
    slashe = $dest.count "/"
    if slashes != slashe
      $dest = $dest + "/"
  t = 0
  loop do  #This loop affixes the extension to the file, checking which extension is proper.
    newfileloc = "D:/Project3/2/" + filename
    t +=1
    case t
    when 1
     newfileloc += ".mp3"
    when 2
      newfileloc += ".wav"
    when 3
      newfileloc += ".ogg"
    when 4
      newfileloc += ".mid"
    when 5
      newfileloc += ".jpg"
    when 6
      newfileloc += ".png"
    when 7
      newfileloc += ".bmp"
    if FileTest.exist?( newfileloc ) == true, $dest)
  while $scene != nil

Anyway, the code works properly, once.  After one file isn't found, this moves the file to the proper location, and after that if another file is missing, it acts as if there were no rescue whatsoever.  I -think- this has to do with the rescue trying to call itself within itself, but I'm not sure.  How can I get around this?

If you couldn't tell, the script is for a game, I've got like 2gigs worth of resources and want the game to sort through the resources on its own, leaving me with the neccecary resources.  Yes, the code works PERFECTLY the first time, it just fails to run subsequent times.