Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Serveur] renommer des fichiers
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index French
View previous topic :: View next topic  
Author Message
Pheatlon
n00b
n00b


Joined: 30 Dec 2007
Posts: 1

PostPosted: Sun Dec 30, 2007 5:00 pm    Post subject: [Serveur] renommer des fichiers Reply with quote

Bonjour à tous

j'ai dans un répertoire plus de 5000 images que je fois renommer. j'ai testé plusieurs commandes trouvées sur le site mais aucune n'arrive à faire ce que je veux.

mes images sont de la forme :

Code:
t_hdjkshdkjqsdhkjq.jpg


et je voudrais que ça devienne:

Code:
t_picture_hdjkshdkjqsdhkjq.jpg


Merci à tous et joyeuses fêtes
Back to top
View user's profile Send private message
Temet
Advocate
Advocate


Joined: 14 Mar 2006
Posts: 2586
Location: 92

PostPosted: Sun Dec 30, 2007 5:41 pm    Post subject: Reply with quote

Dans le dossier avec les images, mets ce script et exécute le:

Code:
#!/bin/bash

for img in *.jpg; do
        prefix=${img%_*}
        suffix=$(echo $img | awk -F"_" '{print $2}')
        mv $img ${prefix}_picture_${suffix}
done


Doit y avoir moyen de faire mieux mais moi je sais pas faire.
_________________
Full Gentoo powered.
Back to top
View user's profile Send private message
Bapt
Veteran
Veteran


Joined: 14 Apr 2003
Posts: 1152
Location: Paris

PostPosted: Sun Dec 30, 2007 5:54 pm    Post subject: Reply with quote

si tu utilise zsh tu as zmv (autoload -U zmv)
Code:
zmv 't_*.jpg' 't_picture_$1.jpg'


Si tu veux tester avant :
Code:
zmv -n 't_*.jpg' 't_picture_$1.jpg'
Back to top
View user's profile Send private message
Temet
Advocate
Advocate


Joined: 14 Mar 2006
Posts: 2586
Location: 92

PostPosted: Sun Dec 30, 2007 6:19 pm    Post subject: Reply with quote

J'ai trouvé mieux ^^

Code:
for img in *.jpg; do mv "$img" ${img%_*}_picture_${img##*_}; done


Commande à lancer dans le bon répertoire bien sûr ^^
_________________
Full Gentoo powered.
Back to top
View user's profile Send private message
Magic Banana
Veteran
Veteran


Joined: 13 Dec 2005
Posts: 1906
Location: Belo Horizonte, Minas Gerais, Brasil

PostPosted: Sun Dec 30, 2007 7:20 pm    Post subject: Reply with quote

Sinon il y a la commande rename qui sert à cela !
Back to top
View user's profile Send private message
Temet
Advocate
Advocate


Joined: 14 Mar 2006
Posts: 2586
Location: 92

PostPosted: Sun Dec 30, 2007 7:25 pm    Post subject: Reply with quote

Oui bah donne la en entier, radin! :lol:
_________________
Full Gentoo powered.
Back to top
View user's profile Send private message
Magic Banana
Veteran
Veteran


Joined: 13 Dec 2005
Posts: 1906
Location: Belo Horizonte, Minas Gerais, Brasil

PostPosted: Sun Dec 30, 2007 7:51 pm    Post subject: Reply with quote

Temet wrote:
Oui bah donne la en entier, radin! :lol:


Ma bonté me perdra :
Renommer les t_*.jpg en t_picture_*.jpg:
$ rename 's/^t_/t_picture_/' *.jpg
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index French All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum