0

I have a lot of files that I need to rename in numerical order. So what I have is this

Getting Started 1.jpg
Getting Started 10.jpg
Getting Started 100.jpg
Getting Started 101.jpg
Getting Started 102.jpg

and what I want to do is rename them so that they are ordered like

Getting Started 001.jpg
Getting Started 002.jpg
Getting Started 003.jpg
Getting Started 004.jpg

is there a simple way to do this?

0

2 Answers 2

1

Create a .bsh file inside the directory in which your images are stored and paste the below code :

#!/bin/bash

count=1

for file in *.jpg
do
    new=$(printf "Getting Started %03d.jpg" "$count")
    mv -- "$file" "$new"
    (( count++ ))
done

Open a Terminal and navigate to the directory in which your script is stored.

To change the permissions of the script :

chmod +x <filename>.bsh

To execute the script :

bash <filename>.bsh

Note: %03d sets pad to length of 3

0

The simplest way to do it is to use a purpose-made application, such as PyRenamer

sudo apt-get install pyrenamer

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