I have a directory
~/mydir/ with many files. Some of these files are
~/mydir/foo.py ~/mydir/foo.tex ~/mydir/foo.pdf ~/mydir/foo.log
I'd like to change any file in
~/mydir/ whose base name is
foo-bar. So, the files above should be renamed as
~/mydir/foo-bar.py ~/mydir/foo-bar.tex ~/mydir/foo-bar.pdf ~/mydir/foo-bar.log
I am not worried about the new file names conflicting with existing files (
$ ls ~/mydir/foo-bar* returns nothing).
It seems like this should be easy to do in bash, but I can't figure it out.
Is there a simple script to accomplish this task?