所以我有一个脚本,它使用$1.audio
文件中的音频将 2 部电影添加到一起。我想做的是重命名目录中的任何文件:
*.mp4
Run Code Online (Sandbox Code Playgroud)
到:
*.audio
Run Code Online (Sandbox Code Playgroud)
保留原始文件名。
您可以使用该rename
命令。它不是可移植的,但它以不同的形式存在于不同的发行版中。
在 CentOS/RHEL 和 Fedora 中:
rename .mp4 .audio *.mp4
Run Code Online (Sandbox Code Playgroud)
应该做。从man rename
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.
Run Code Online (Sandbox Code Playgroud)
在 Ubuntu 和可能的任何 Debian 变体中:
rename 's/\.mp4$/.audio/' *.mp4
Run Code Online (Sandbox Code Playgroud)
应该这样做。从man rename
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
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2642 次 |
最近记录: |