Rename multiple files on shell

To rename multiple files in the current folder, you can use the following command:

$> # rename:
$> for f in Sheldon_*.xml; do mv -n "$f" "${f}_bkp"; done
$> # rename it back again:
$> for f in Sheldon_*.xml_bkp; do mv -n "$f" "${f/_bkp}"; done

In this case, I had a bunch of files that I had to rename temporarily. They all started with Scheldon_ and had the fileending .xml. The snippets above first rename these files to Scheldon_SOMEWHAT.xml_bkp and then back to the original name Scheldon_SOMEWHAT.xml.

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.