Bash

Rename extensions of multiple files

Published on May 27th, 2020


In this example, we're going to change a list of .txt files to .md files:


#!/bin/bash

shopt -s nullglob
files=($(ls -v *.txt))

for file in "${files[@]}"
do
    mv ${file} ${file}.md
done

You can use modify this script to rename any extension you want.