Renommer groupe de fichier

Bonjour,

je sais qu’il ya déjà d’autres postes et explication sur google pour renommer un groupe de fichier dans un dossier depuis un terminal, mais je ne comprends pas trop les commandes…
je vous explique les deux situations: la première j’ai un dossier avec des films pris depuis une caméra qui a comme nom img_suivi de chiffre, j’aimerai simplement enlever le début du nom des fichiers, donc supprimer img.
dans un autre dossier j’ai la même situation mais j’aimerais remplacer img par un autre nom (activité prise avec la caméra) donc img_chiffre par sport_chifre.

si quelqu’un à une idée elle est la bienvenue, d’avance merci

Bonsoir

Voir :

man rename

michel@debg53sw:~/tstNomsImg$ ls -l
total 0
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_101617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_111617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_121617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_131617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_141617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 img_20170715_151617.3gp
michel@debg53sw:~/tstNomsImg$ 
michel@debg53sw:~/tstNomsImg$ rename 's/^img_//' *
michel@debg53sw:~/tstNomsImg$ 
michel@debg53sw:~/tstNomsImg$ ls -l
total 0
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_101617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_111617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_121617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_131617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_141617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:52 20170715_151617.3gp
michel@debg53sw:~/tstNomsImg$ 

michel@debg53sw:~/tstNomsImg$ ls -l
total 0
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_101617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_111617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_121617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_131617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_141617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 img_20170715_151617.3gp
michel@debg53sw:~/tstNomsImg$ 
michel@debg53sw:~/tstNomsImg$ rename 's/^img/sport/' *
michel@debg53sw:~/tstNomsImg$ 
michel@debg53sw:~/tstNomsImg$ ls -l
total 0
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_101617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_111617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_121617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_131617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_141617.3gp
-rw-r--r-- 1 michel michel 0 août  18 20:54 sport_20170715_151617.3gp
michel@debg53sw:~/tstNomsImg$ 

je viens de testé, la première commande ne fonctionne pas, mais la suivante parfaitement
pour ce qui est de la première elle ne renvoi pas d’erreur mais applique pas la suppression de img

c’est déjà une bon aide pour un bon classement.

encore merci

voilà grâce à toi j’ai trouvé la solution… voilà il fallait juste modifié un peux la commande et ça à fonctionné correctement.
rename “s/img_*//g” *.3gp

salut

non google ne fait que voler les infos des autres

j’avais oublié son existence , alors que man rename donne > rename - renames multiple files

souvent j’utilise

for i in *; do mv $i $(echo $i |sed ‘s/^img_/machin_/’) ; done

et je confirme les commandes de MicP fonctionnent : l’accent circonflexe ^ signifie “le début du fichier”

ok mais chez moi, ces sns le ^. par contre pour remplacer un mot il y avait aucun soucis.