HowTo: Unix / Linux Rename File Extension From .OLD to .NEW
To rename a file extension from .OLD to .NEW in Unix or Linux, you can use the mv (move) command along with string substitution and a shell loop. Here is an example using a shell script:
#!/bin/bashfor f in *.OLD; do
n mv "$f" "${f%.OLD}.NEW"
doneThis script will loop through all files with a .OLD extension in the current directory and rename them with a .NEW extension using the mv command. The ${f%.OLD}.NEW syntax uses string substitution to remove the .OLD extension from the file name and add the . (https://semidotinfotech.com) NEW extension in its place.
After saving this script to a file, for example rename_extension.sh, make it executable with the following command:
chmod +x rename_extension.shAnd then run the script:
./rename_extension.shThis will rename all files with a .OLD extension in the current directory to have a .NEW extension instead.
n