Change files extension in a directory

A onliner for f in *.old; do mv "$f" "${f%.old}.new"; done How??? To change the name of a file on Linux/Unix use the mv command mv currentfilename newfilename If there is a file named aleemisiaka.old and want to rename to aleemisiaka.new We can store the filename to a variable with export FILENAME=aleemisiaka And use the variable name in the mv command mv "$FILENAME"$ "$FILENAME.new" This renames the file from aleem-isiaka.old to aleemisiaka....

June 22, 2023 · 1 min · Aleem Isiaka