Tech TLDR;

  • Archive
  • Top Posts
  • GitHub
  • LinkedIn
  • Contact

Batch Rename Files in Unix Command Line

June 27, 2014 by admin

Sometimes the unix shell script is still the best tool for the job.

Today I needed to rename a bunch of java properties files from *.property to *.json. Ok, I needed to do more then just rename them, but it makes the example easier to assume that is all that I needed done ๐Ÿ™‚

I wrote the following script in rename.sh file.

#!/bin/bash          
for file in *.properties; do
  mv "$file" "${file%properties}json"
done
Code language: JavaScript (javascript)

Then I ran chmod +x rename.sh followed by ./rename.sh to run the file. Done.

It’s a small example, but it demonstrates well just how powerful bash scripts can be.

Filed Under: Uncategorized

Copyright © 2025 ยท eleven40 Pro Theme on Genesis Framework ยท WordPress ยท Log in