Skip to main content
3 of 5
Expanded answer
Greenonline
  • 2.1k
  • 7
  • 23
  • 32

This command would seem to do what you wish

for file in *.* ; do cp $file ${file//a\./b\.} ; done

Adapted from this answer to Renaming part of a filename

Actually, you could just do

for file in * ; do cp $file ${file//a\./b\.} ; done

Note that the . has to be escaped using \.. This is primarily because your example is a filename of a single letter, which could potentially conflict with a letter in the extension.

If your filenames are a bit more explicit, such as doggy.txt, doggy.pdf, doggy.xls, etc., and you want to change them to feline.txt, feline.pdf, ..., etc., then you could do away with escaping the . (and the . all together), like so:

for file in *.* ; do cp $file ${file//doggy/feline} ; done
Greenonline
  • 2.1k
  • 7
  • 23
  • 32