Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this community
Anybody can ask a question
The best answers are voted up and rise to the top
How can I rename a lot of files using a regex?
Rename All Files with a Certain Name
There are files with
and so on..
I need to rename them to
and so on..
How can I do that?
asked Jan 17, 2012 at 15:32
rename -n 's/(.*)_20120117/$1_20120113/' ORDER_EVENTS*
once you sure this is it, remove the
answered Jan 17, 2012 at 15:53
Michał ŠrajerMichał Šrajer
2,7981616 silver badges1717 bronze badges
rename 's/20120117/20120113/' ORDER_EVENTS_*20120117.log
This assumes that all the files to be renamed are in the same directory.
answered Jan 17, 2012 at 15:52
Nikhil MulleyNikhil Mulley
8,0873232 silver badges4949 bronze badges
Or use mmv:
mmv "*17.log" "#1\13.log"
answered Jan 17, 2012 at 18:37
daniel kullmanndaniel kullmann
9,3171111 gold badges3636 silver badges4545 bronze badges