Write Simple Shell Command to Rename Entire file .txt to .js in Linux
July 23 2016
Assume that, some files are stored in my user path with .txt suffix. If you want to rename them all to follow this pattern. For example filenamelinux.txt to filenamelinux.js
$ cd /home/thelinuxfaq/
$ ls
$ ls
aSSb6EW7dfNUO52hQkae.txt hE2uvdMIAJvEWpZaWxsJ.txt nibzU9psJ4RICO88kofp.txt TyhMgWml4au4zgDSivRc.txt ZUweKr0Z12PSmVTFUdh3.txt
atoKLauqBT3qLNuehQXF.txt filenamelinux.txt
Execute the below command to chnage file types,
for j in *.txt; do mv -v -- "$j" "${j%.}.dat"; done
Comments (0)