July 12, 2023

Rename multiple files from the command line

To rename an occurence in multiple files run:

   $ rename.ul expression replacement files

expression is the occurence of the expression to be replaced. replacement is the part of the expression that will be replaced. files is the name of the files.

For example, if you want to replace IMG by _IMG in all the files starting by IMG, run

$ rename.ul IMG _IMG IMG*

Another example:

$ rename.ul foo foo00 foo?


    $ rename.ul foo foo0 foo??

will turn the files foo1, …, foo9, foo10, …, foo278 into foo001, …, foo009, foo010, …, foo2781.


     $ rename.ul .htm .html *.htm

will fix the extension of your html files2.


     $ rename '_with_long_name' '' [filenames]*

will remove the substring in the filenames.

Run $ man rename.ul to display the manual and see the options.

  1. Example from the man page.↩︎

  2. Ibid.↩︎

command-line interface (cli) gnu linux trisquel text processing office applications personal computing wiki shell literacy

No affiliate links, no analytics, no tracking, no cookies. © 2016-2023 yctct.com. Content is licensed under CC BY-NC-SA 4.0 .