0

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

0

1 Answer 1

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’
3
  • 1
    Quote your variables... Commented Dec 18, 2014 at 8:59
  • Thanks, Rename is fine, But I want to rename files by a name list renamelist.txt not all folder Commented Dec 18, 2014 at 9:14
  • Gary Lau "find . -type f -name 'IMG'" in this way find command only works on files. Commented Dec 18, 2014 at 13:58

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.