How to rename multiple files by removing the extension?

perl's rename (as typically found on Debian where it's also called prename), or this derivative (rename package on Debian):

rename 's/\.tif$//' *.tif

util-linux rename (as typically found on Red Hat, rename.ul on Debian):

rename -- .tif '' *.tif

(note that that one would rename blah.tiffany.tif to blahfany.tif)


For a non-rename, you might do:

$ for i in *.tif; do mv -i $i `basename $i .tif`; done

(-i to warn against replacing a file)


If you use IBM AIX you won't have a rename command, so in order to batch remove file extensions you'll have to use plain vanilla System V UNIX commands:

for file in *.tif; do
   mv $file `echo $file | sed 's/.tif$//'`;
done;

Tags:

Rename