This question already has an answer here:
I've been making simple bash functions for this with
find -exec or parsing ls or using bash globbing etc each time I had a big problem and I had to go to a new method one time it was argument list too long another time files that already had a name like
2 was overwritten when another file was being renamed to
One time it was a problem with unicode, one time with space in the file name, one time with
& in the filename and so on. So I thought I'd come here and ask you people for the most efficient and robust general purpose way to rename all the files in a directory to have sequential names no matter what!. No matter how long the names of the files are and no matter what their original name is or what extension they have and no matter if they have non-ASCII characters in them.
So my requirements are:
- That it works with long filenames.
- That it works with unicode characters.
- That it works if the files have space or special characters in them.
- That it does not overwrite any file on another.
- That it is as fast as possible:D