You probably want a chomp at the top of the loop?
In reply to Re^2: rename files by gwadej in thread rename files by pbaumgar