+5 votes
in Operating Systems by (40.5k points)
edited by
I want to replace the ".jpeg" extension with ".jpg" in all image files in a folder. What bash command should I use to do this?

1 Answer

+3 votes
by (348k points)
selected by
Best answer

To replace the ".jpeg" extension with ".jpg" in images files in a folder, you can use the "mv" command with the "for" loop.

  • "cd" to the folder where you have kept your image files.
  • run the following command on the terminal.

for file in $(ls *.jpeg);  do mv "$file" "${file%.*}.jpg" ; done