-1

How to rename a group of files

tl_0014_0010_20151212_133443.jpg
tl_0014_0010_20151212_133543.jpg
tl_0014_0010_20151212_133643.jpg
...

to

photo00000.jpg
photo00001.jpg
photo00002.jpg
...

?

aspire89
  • 101
  • 1

1 Answers1

1

To get you started:

i=0
for file in tl*.jpg
do
    printf -v counter "%05d" $i
    mv $file photo$counter.jpg
    i=$((i+1))
done

The printf command ensures the counter has leading zeroes.

Note that I didn't test this.

berndbausch
  • 3,557
  • The -v option to printf is a shell extension that's not supported in most Bourne shells. A more portable method is counter=$(printf "%05d" "$i"). – RobertL Dec 12 '15 at 14:07