Replace filename suffixes

It is quite obvious and easy at all, but for the reference and to save the time looking up on Google again (because I probably always have to re-read the manpage or Google search)…

$ for i in *.eml; do mv "$i" $(basename -s .eml "$i").txt; done

It stips off the eml extension of any file in the current directory and replaces it with txt. The files get actually just moved to the new filename.

Leave a Comment