Make Conversion Of File Names To Alphabet Letters

Convert File Names To Alphabet Letters

For example , I have several Image/Photo files in a directory, and I want to pass these extensive names of the respective images into names designated by letters of the alphabet

Before

IMG01-03082016.jpg

IMG02-03082016.jpg

IMG03-03082016.jpg

Etc ...

After

A.jpg

B.jpg

C.jpg

Etc ...

Author: Comunidade, 2016-08-21

2 answers

Follows tested solution to the problem:

#/bin/bash

n=0

alfabeto=$(echo {A..Z})

find . -maxdepth 1 -name '*.jpg' -type f  | while read imagem; do

    mv "${imagem}" "${alfabeto[n++]}.jpg"

done

exit 0

#fim-de-arquivo#
 1
Author: Lacobus, 2016-11-14 14:25:41

The comment of JJoao and the answer of Lacobus got me to the shell-script :

 #!/bin/sh
 #
 # Por - Diego Henrique
 #
 # Programa - Renomear Arquivos Para Letras Do Alfabeto
 #
 # NOTA - Deve-se ter no máximo 26 Arquivos, alojado neste diretório 
 # Isso se dá ao número no qual corresponde as 26 Letras Alfabéticas 
 #
 n=0; LETRA=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);

 ls $HOME/*.png | while read IMG; do mv "$IMG" "${LETRA[n++]}.png"; 

 done

This is what worked perfectly on my Pinguin System - Damn small Linux


About my own experience (errors/hits), I decided to leave this as an absolute answer.

 1
Author: Diego Henrique, 2016-08-29 14:51:27