Bonjour
pseudofab
pseudofab a écrit… Que signifit le ~ dans l'expression régulière de rename?
Ce n'est pas un opérateur de l'expression rationnelle,
c'est simplement que l'option
--backup=numbered de la commande
mv
ajoute à la fin du nom des fichiers doublons
un point suivit d'un numéro entre deux caractères
~
Comme ci-dessous :
michel@ubuT450:~/tests$ ls -l
.:
total 0
michel@ubuT450:~/tests$
michel@ubuT450:~/tests$ mkdir src/{,src1,src2} repCible && touch src/{,src1/,src2/}"fich "{a..c}.jpg
michel@ubuT450:~/tests$ ls -lR src/ repCible/
repCible/:
total 0
src/:
total 8
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg'
drwxrwxr-x 2 michel michel 4096 nov. 22 14:31 src1
drwxrwxr-x 2 michel michel 4096 nov. 22 14:31 src2
src/src1:
total 0
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg'
src/src2:
total 0
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg'
michel@ubuT450:~/tests$ find src/ -iname '*.jpg' -exec mv --backup=numbered -t repCible/ {} +
michel@ubuT450:~/tests$ ls -lR src/ repCible/
repCible/:
total 0
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg.~1~'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg.~2~'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg.~1~'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg.~2~'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg.~1~'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg.~2~'
src/:
total 8
drwxrwxr-x 2 michel michel 4096 nov. 22 14:32 src1
drwxrwxr-x 2 michel michel 4096 nov. 22 14:32 src2
src/src1:
total 0
src/src2:
total 0
michel@ubuT450:~/tests$ rename 's/((?:\..+)?)\.~(\d+)~$/$2$1/' repCible/*.~*~
michel@ubuT450:~/tests$ ls -l repCible/
total 0
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a1.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a2.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich a.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b1.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b2.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich b.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c1.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c2.jpg'
-rw-rw-r-- 1 michel michel 0 nov. 22 14:31 'fich c.jpg'
michel@ubuT450:~/tests$
michel@ubuT450:~/tests$ rm -rf src/ repCible/
michel@ubuT450:~/tests$