So you have a group files with an unuseful name for another program or service you are using and you want to rename the whole group.

Here is the solution:
# basic file renamer


for i in $( ls *$criteria* ); 
   tgt=$(echo $i | sed -e "s/$re_match/$replace/")
   mv $src $tgt

It is used as such:

./ csv '201606' '2016-06'

It uses sed and that allows all of the regex you might be familiar with, a la:


I won’t go into heavy regex usage here, there are several good articles/guides out there on that. One day I might post a conglomeration of those with most used by myself at the top with any additional items I’ve found that are helpful.

Also, I definitely found this and copied it verbatim from: which is a great resource for anyone wanting to expand their knowledge/skills on a well organized knowledge system. Thank you TLDP, you’ve been a great resource for years to date. ^_^

Leave a comment

Your email address will not be published.

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