0

Possible Duplicate:
How can I rename a lot of files using a regex?
Rename All Files with a Certain Name

There are files with

ORDER_EVENTS_SOMETHING_20120117.log
ORDER_EVENTS_SOME2_20120117.log
ORDER_EVENTS_CHARS_20120117.log

and so on..

I need to rename them to

ORDER_EVENTS_SOMETHING_20120113.log
ORDER_EVENTS_SOME2_20120113.log

and so on..

How can I do that?

0

3 Answers 3

6

do:

rename -n 's/(.*)_20120117/$1_20120113/' ORDER_EVENTS*

once you sure this is it, remove the -n option.

2
  • Nikhil did easier regexp (+1). Anyhow I will leave this for the reference. Jan 17, 2012 at 15:55
  • +1 for hint on -n switch
    – feeela
    Sep 18, 2012 at 21:22
4
rename 's/20120117/20120113/' ORDER_EVENTS_*20120117.log

This assumes that all the files to be renamed are in the same directory.

0

Or use mmv:

  mmv "*17.log" "#1\13.log"