I needed to rename a bunch of .txt files to .json and I was too lazy to hand type it.
I found a quick bash script which can be ran in Mac OSX Terminal or any shell.
Renaming the files (dry run)
This script will print out the new file names but won't rename them. This is to ensure, the bash script is renaming correct .txt files.
cd into the directory
2) Then type in the command
touch rename.sh. This will create a new shell script.
3) We need to set permissions first by making it executable.
chmod 755 rename.sh.
4) Copy and paste this to
Renaming .txt to .json
If your dry run is successful, then we can remove
echo from script.
echo is a print function of bash, similar to
You can run this script for any file extension as long as you change the .txt and json.