bash rename using regex array substitution
Posted
by
mulllhausen
on Stack Overflow
See other posts from Stack Overflow
or by mulllhausen
Published on 2010-12-28T00:47:36Z
Indexed on
2010/12/28
0:54 UTC
Read the original article
Hit count: 522
hi, i have a very similar question as for this post.
i would like to know how to rename occurances within a filename with designated substitutions. for example if the original file is called: 'the quick brown quick brown fox.avi' i would like to rename it to 'the slow red slow red fox.avi'.
i tried this:
new="(quick=>'slow',brown=>'red')"
regex="quick|brown"
rename -v "s/($regex)/$new{$1}/g" *
but no love :(
i also tried with
regex="qr/quick|brown/"
but this just gives errors. any idea what im doing wrong?
© Stack Overflow or respective owner