-1

I have hundreds of image files (.jpg) with different names with nothing in common; e.g., 12223.jpg, beautiful-ocean.jpg, aWkqi.jpg. How can i rename them all in series, such as 1.jpg, 2.jpg, 3.jpg...

1

1 Answer 1

1

One could rename the files as 001.jpg, 002.jpg, ... 999.jpg in bash by:

declare -i num=1
for file in *.jpg ; do
    printf -v newname "%03d.jpg" $num
    num=$(( num + 1 ))
    echo mv "$file" "$newname"
done

Change "echo mv" to "mv" when you're happy with the generated results.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .