Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a tonne of files called File30_i.txt for i=1, 2, 3, 4, 5... Is there an easy way to quickly rename then File20_i.txt for example?

share|improve this question
up vote 3 down vote accepted

There is a tool for that called rename:

rename 's/File30/File20/' *.txt

For a preview run with -n:

rename -n 's/File30/File20/' *.txt
share|improve this answer

My preferred way would be to use sed to generate a script for it, for example:

ls -1|sed 's/File30_\([^.]*\).txt/mv & File20_\1.txt/'|bash

This should rename as per the filenames you gave in the question. To preview the commands, you can do:

ls -1|sed 's/File30_\([^.]*\).txt/mv & File20_\1.txt/'
share|improve this answer

renamer works on Windows, Mac and Linux:

$ renamer --find Find30 --replace Find20 *.txt
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .