How do I rename the extension for a bunch of files?

In a directory, I have a bunch of *.html files. I’d like to rename them all to *.txt

How can I do that? I use the bash shell.

28 s
28

If using bash, there’s no need for external commands like sed, basename, rename, expr, etc.

for file in *.html
do
  mv "$file" "${file%.html}.txt"
done

Leave a Comment