Question: Example of usage (contrived!): rename .mp3 files to .txt.

I'd like to be able to do something like

```
find -name '*.mp3' -print0 | xargs -0 -I'file' mv file ${file%.mp3}.txt

```

This doesn't work, so I've resorted to piping `find`'s output through `sed -e 's/.mp3//g'`, which does the trick.

Seems a bit hackish though; **is there a way to use the usual bash `${x%y}` syntax?**

Answer: 
Just to add another suggestion, even though it doesn't use the shell's substitution mechanism, but instead, sed's.

```
find -name '*.mp3' -print |
sed -e 's/\.mp3$//' -e "s/.*/mv '&\.mp3' '&\.txt'/" |
sh

```

In other words, create an `mv` command line for each file name, and pass the result to `sh`.

This will fail if any of the files have an apostrophe (single quote) in their file name. I mainly post this to counter the "if all you have is xargs, every problem will look like a nail" syndrome.

Not all seds have exactly the same syntax. In particular, I'm not 100% sure you can have multiple -e arguments on some crufty old SunOS (look for the XPG-compatible sed in something like `/usr/ucb/blah/barf/vomit/xpg4/bin/sed`)
```
perl rename.pl 's/\.mp3$/.txt/' *.mp3  
# Or **/*.mp3 for zsh and bash with specific settings set, for a recursive 
# rename.

```

<http://people.sc.fsu.edu/~jburkardt/pl_src/rename/rename.html>