0

This question already has an answer here:

Command for rename file as IMG0001 to 4R0001 in folder

for f in *;do mv "$f" `echo "$f" | sed 's/IMG/4R/g' `; done

AND

I just want rename selected folder

/tmp/2014/1201 (rename files)
/tmp/2014/1202
.......
/tmp/2014/1220
/tmp/2014/1224 (rename files)
/tmp/2014/1227 
.......

find not good for selected folder

awk for selected folder by renamelist.txt but miss match with for loop $value

Thanks

marked as duplicate by garethTheRed, jasonwryan, Hauke Laging, Networker, jimmij Dec 18 '14 at 10:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from serverfault.com Dec 18 '14 at 8:20

This question came from our site for system and network administrators.

0

The more easy way is use bash substitution in this way:

for i in $(find . -name '*IMG*');do mv -v $i ${i//IMG/RG}; done
‘./IMG001.img’ -> ‘./RG001.img’
  • 1
    Quote your variables... – jasonwryan Dec 18 '14 at 8:59
  • Thanks, Rename is fine, But I want to rename files by a name list renamelist.txt not all folder – Gary Lau Dec 18 '14 at 9:14
  • Gary Lau "find . -type f -name 'IMG'" in this way find command only works on files. – c4f4t0r Dec 18 '14 at 13:58

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