Linux: change a large number of file names, all at once

Tags:

How do I change a lot of file names all at once, and using the linux command line?  Look no further.  Let’s say you have a bunch of images in your current directory (let’s create them like so for testing purposes):

for x in {1..100}; do touch “image$x.gif”; done

Now that you have all 100 gif images files, just run the following command to change them to have the .jpg file extension:

for x in *.gif; do mv “$x” “${x%.gif}.jpg”; done

And presto, there you go!  Your .gif files are now .jpg files. 

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
12 + 1 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.