megacolorboy

Back

Published on May 27th, 2020

Bash

Rename extensions of multiple files

In this example, we're going to change a list of files to files:You can use modify this script to rename any extension you want.

1 minute read

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.