I have checked the other answers but didn't find anything matches with my case. Question is simple. How can I do the following:

rename *A*X*.csv *A*Y*.csv 

I know that the above line is in the Windows style but I think you got what I want. So all the files which include A before X is changed to *A*Y*.csv Because in my case I also have files with *B*X*.csv format and I don't want them to be changed.

An example:

myfileAisblablaXblabla.csv => myfileAisblablaYblabla.csv 

And I have to say that there are lots of these kind of files in my case, so I need a batch solution. Thanks.


rename could substitute character in the file name like sed sintax working for you should be (test it before run):

rename s/X/Y *A*X*.csv
  • You should single-quote the substitution pattern, terminate the replacement and make use of -n option: rename -n 's/X/Y/' *A*X*.csv – pLumo Apr 30 at 8:11
  • @RoVo -n option of rename is --nono for simulate the action but do not apply. – AtomiX84 Apr 30 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.