3

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 2.

One time it was a problem with unicode, one time with space in the file name, one time with * or & 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:

  1. That it works with long filenames.
  2. That it works with unicode characters.
  3. That it works if the files have space or special characters in them.
  4. That it does not overwrite any file on another.
  5. That it is as fast as possible:D

marked as duplicate by dessert, Eric Carvalho, Charles Green, vidarlo, pa4080 Feb 15 '18 at 21:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Seems like an advertisement to use python :) – Jacob Vlijm Feb 15 '18 at 13:57
  • 1
    You should really provide an example filename set. What do you mean by "sequential names"? does the relationship between the input lexical order and output numerical order matter, and if so what should it be? – steeldriver Feb 15 '18 at 14:06
  • The easiest (and fastest I suppose) would be rename, but as Oli explained it perfectly in the duplicate question I linked I won't add an answer here. – dessert Feb 15 '18 at 14:24
2

If your Ubuntu isn't a server don't treat it like one. pyRenamer from the default Ubuntu repositories has all the features that you are looking for including regex support, and since it's a GUI program you don't need to break your head trying to figure out how to use it. If you are having trouble writing a regular expression, you can get an explanation of what your regex does at RegExr. Don't allow yourself to become biased against GUI programs that were created for use cases like this.

pyRenamer is available from the default Ubuntu repositories in Ubuntu 16.04 and earlier. In Ubuntu 18.04 and later pyRenamer has been replaced by GPRename.

  • I'm sorry but it is! but this is also very useful because I also want to do in on my laptop many times. – yukashima huksay Feb 15 '18 at 13:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.