how to change a part in multiple filenames from 1 to 01?

空扰寡人 提交于 2020-01-25 12:47:27

问题


I have lots of files in a directory.

Example:

 "/data/2014/file300.data.20141231.MC.9.vgf.img"

here 9 represent the hour and change from 1 to 24,the date also change. the hours are represented .1. .2. .3. .4. .... .9. I want to replace this part(only this part) in the file name with .01. .02. .03. .04. .... .09. and do not touch any other number in the file name.

so .1. become .01. and so on


回答1:


Try this with Larry Wall's rename to replace .MC. by .MC.0:

rename 's/\.MC\./.MC.0/' /data/2014/*.img


来源:https://stackoverflow.com/questions/31525621/how-to-change-a-part-in-multiple-filenames-from-1-to-01

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!