(4 risposte)
Chiuso 5 anni fa.
Quindi ho una sceneggiatura che aggiunge 2 film insieme usando l'audio di $1.audio
file. Quello che vorrei fare è rinominare qualsiasi file nella directory con:
*.mp4
A:
*.audio
Mantenimento del nome del file originale.
Risposta accettata:
Puoi usare il rename
comando. Non è portatile, ma esiste in forme diverse in diverse distribuzioni.
In CentOS/RHEL e probabilmente in Fedora:
rename .mp4 .audio *.mp4
Dovrebbe farlo. Da man rename
su 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 e probabilmente in qualsiasi variante di Debian:
rename 's/.mp4$/.audio/' *.mp4
dovrebbe farlo. Da man rename
su 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