Say I have a listing of files with the same name, but different file extensions:
name.a
name.b
name.c
...
name.z
and want to rename them to:
newname.a
newname.b
newname.c
...
newname.z
How could I do this rename operation in one bash command?
Say I have a listing of files with the same name, but different file extensions:
name.a
name.b
name.c
...
name.z
and want to rename them to:
newname.a
newname.b
newname.c
...
newname.z
How could I do this rename operation in one bash command?
You can use rename utility:
rename 's/^name\./newname./' name.*
You can use parameter expansion:
for f in name.*; do
ext="${f##*.}"
mv "$f" "newname.$ext"
done
There is an excellent write-up about it here