DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Change File Extensions With Bash Shell

  • submit to reddit
        To change all .htm files in a folder to .html files:

for f in *.htm; do mv $f `basename $f .htm`.html; done;


Snippets Manager replied on Thu, 2009/03/12 - 11:19am

If you've got spaces in your filenames, this is a more fullproof version: for f in *.MP3; do mv "$f" "`basename "$f" .MP3`.mp3"; done;