I have a directory of files$ ls -1ep2.mp4ep3.mp4ep4.mp4ep5.mp4ep6.mp4ep7.mp4I want to use the perl rename utility to make all files look like e.g.ep02.mp4 Command I am usingrename -n s/([0-9])/0${1}/ *.mp4current resultep2.mp4 renamed as ep0.mp4ep3.mp4 renamed as ep0.mp4ep4.mp4 renamed as ep0.mp4ep5.mp4 renamed as ep0.mp4ep6.mp4 renamed as ep0.mp4ep7.mp4 renamed as ep0.mp4How can I capture the original digit and insert into the new filename?
Why isn't this perl regex capturing the backreference?
shell;perl;quoting;rename
Use single quotes (or escape with \) around the replacement statement, otherwise shell will treat ${1} as variable.So you can do:rename -n 's/([0-9])/0${1}/' *.mp4Orrename -n s/([0-9])/0\${1}/ *.mp4