(4 Antworten)
Vor 5 Jahren geschlossen.
Ich habe also ein Skript, das 2 Filme zusammenfügt, indem es das Audio aus $1.audio
verwendet Datei. Was ich tun möchte, ist, eine beliebige Datei im Verzeichnis umzubenennen mit:
*.mp4
An:
*.audio
Ursprünglichen Dateinamen beibehalten.
Akzeptierte Antwort:
Sie können den rename
verwenden Befehl. Es ist nicht portabel, aber es existiert in verschiedenen Formen in verschiedenen Distributionen.
In CentOS/RHEL und wahrscheinlich Fedora:
rename .mp4 .audio *.mp4
Sollte es tun. Von man rename
unter 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.
In Ubuntu und wahrscheinlich jeder Debian-Variante:
rename 's/.mp4$/.audio/' *.mp4
Sollte es tun. Von man rename
unter 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