(4 réponses)
Fermé il y a 5 ans.
J'ai donc un script qui ajoute 2 films ensemble en utilisant l'audio du $1.audio
dossier. Ce que je voudrais faire, c'est renommer n'importe quel fichier du répertoire avec :
*.mp4
À :
*.audio
Conserver le nom de fichier d'origine.
Réponse acceptée :
Vous pouvez utiliser le rename
commande. Il n'est pas portable, mais il existe sous différentes formes dans différentes distributions.
Sous CentOS/RHEL et probablement Fedora :
rename .mp4 .audio *.mp4
Devrait le faire. De man rename
sur CentOS 6 :
SYNOPSIS
rename from to file...
rename -V
DESCRIPTION
rename will rename the specified files by replacing the first occur-
rence of from in their name by to.
Dans Ubuntu et probablement n'importe quelle variante Debian :
rename 's/.mp4$/.audio/' *.mp4
devrait le faire. De man rename
sur Ubuntu 14.04 :
SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ]
DESCRIPTION
"rename" renames the filenames supplied according to the rule specified
as the first argument. The perlexpr argument is a Perl expression
which is expected to modify the $_ string in Perl for at least some of
the filenames specified. If a given filename is not modified by the
expression, it will not be renamed. If no filenames are given on the
command line, filenames will be read via standard input.
For example, to rename all files matching "*.bak" to strip the
extension, you might say
rename 's/.bak$//' *.bak