This doesn’t work, and I know it doesn’t work because I’ve made the same mistake before. And before that. And many times before that.

Fortunately for me, all of this was in a git repository, so I discard that changes and start again.

% git checkout -- .

The problem is one of paths. $File::Find::name has the full path to a file. The callback gets just the filename in $_, which is why I can use that for the regex target with a false match from some other path portion. However, when I do the rename, I take the path and move it to a file in the current directory. All files collapse into the same file and whoever gets there last wins.

I have to be more careful. I get the directory name and prepend it to the new file name: