Rename file extensions easily with bash
Submitted by altj on Tue, 06/12/2007 - 16:18
I recently had a misconfiguration in logrotate that left me with a bunch of bzip2 files having a .gz (gzip) extension on their filename instead of .bz2.
Not to worry, it was a simple fix to rename them all with one command:
for filename in *.gz; do mv $filename `basename $filename .gz`.bz2; done

Or just use mmv: mmv
Or just use mmv:
mmv '*.gz' '#1.bz2'
Thanks for the tip,
Thanks for the tip, Christian. I've now added mmv to my toolchest.
Post new comment