# renaming multiple files while replacing string

**URL:** <https://community.unix.com/t/renaming-multiple-files-while-replacing-string/239716>\
**Category:** Shell Programming and Scripting\
**Created:** [May 9, 2009, 11:27pm UTC](https://community.unix.com/t/renaming-multiple-files-while-replacing-string/239716 "2009-05-09T23:27:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin9](https://community.unix.com/letter_avatar/kevin9/32/6_449c533f586939b6e5f246632a46421f.png) [@kevin9](https://community.unix.com/u/kevin9)\
**Post date:** [May 9, 2009, 11:27pm UTC](https://community.unix.com/t/renaming-multiple-files-while-replacing-string/239716/1 "2009-05-09T23:27:35Z")

</div>

hi,

i've found a few examples of scripts to do this but for some reason can't get them to work properly.

basically i have some dirs with a few hundred files mixed in with a bunch of other files that were made with a typo in part of them.

long-file-names-tyo-example.ext

want to be able to run something through the dir and rename every file with 'tyo' in the file name to the correct 'typo' string

long-file-names-typo-example.ext

any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![ghostdog74](https://community.unix.com/letter_avatar/ghostdog74/32/6_449c533f586939b6e5f246632a46421f.png) [@ghostdog74](https://community.unix.com/u/ghostdog74)\
**Post date:** [May 10, 2009, 7:53am UTC](https://community.unix.com/t/renaming-multiple-files-while-replacing-string/239716/2 "2009-05-10T07:53:33Z")

</div>

```nohighlight
for files in *tyo*.ext
do
  mv "$files" "${files/tyo/typo}"
done 

```

---

<div class="post-metadata">

**Author:** ![kevin9](https://community.unix.com/letter_avatar/kevin9/32/6_449c533f586939b6e5f246632a46421f.png) [@kevin9](https://community.unix.com/u/kevin9)\
**Post date:** [May 10, 2009, 6:41pm UTC](https://community.unix.com/t/renaming-multiple-files-while-replacing-string/239716/3 "2009-05-10T18:41:14Z")

</div>

thank you very much, this worked great.
