Batch remove extensions in Ubuntu

Sometimes you will want to batch remove extensions from a load of files:

for i in $(ls *.png); do mv $i ${i%.png}; done

If you want to remove extensions from files with a .txt extension then you would replace the two instances of .png in the script above with .txt.

You can take the extension off of all files using the following:

for i in $(ls *.*); do mv $i ${i%.*}; done

I also extended it by using it for a batch change of extensions rather than just removing the extension:

for i in $(ls *.html); do mv $i ${i%.html}.htm; done

Note the extra .htm after the curly braces in the above command.