Bash Scripts to rename file name based on nth occurence -
i have below file names:
file-photo01-dfakdj.jpg file-photo02-bjkadf.jpg file-photo03-annunioo.jpg ...
how use rename
command or other bash command rename file names to:
file-photo01.jpg file-photo02.jpg file-photo03.jpg ...
with rename
command,
rename 's/-[^-]+\.jpg$/.jpg/' *.jpg
(or)
with bash
1 liner,
for file in *.jpg; mv "$file" "${file%-*}.jpg" ; done
instead of *.jpg
can specify list of file names want rename.
Comments
Post a Comment