← 返回命令列表

Linux command

prename 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Rename with Perl expression

prename 's/old/new/' [*.txt]

Dry run

prename -n 's/pattern/replacement/' [files]

Lowercase filenames

prename 'y/A-Z/a-z/' [*]

Remove spaces

prename 's/ /_/g' [*]

Add prefix

prename 's/^/prefix_/' [*]

Add suffix before extension

prename 's/(\.[^.]+)$/_suffix$1/' [*]

Verbose output

prename -v 's/old/new/' [files]

说明

prename (Perl rename) renames files using Perl expressions. It provides powerful pattern-based renaming. The s/// substitution operator replaces text. Global flag g replaces all occurrences. Transliteration y/// transforms character sets. Useful for case changes. Perl code can use $_ for filename. Complex transformations are possible. Dry run shows what would happen. Always test patterns before applying. Multiple expressions chain transformations. Each -e adds another operation.

参数

-n, --no-act
Dry run, show changes.
-v, --verbose
Show renames.
-f, --force
Overwrite existing files.
-0, --null
Null-separated input.
-e _EXPR_
Expression to apply.
-E _EXPR_
Like -e but without warnings.

FAQ

What is the prename command used for?

prename (Perl rename) renames files using Perl expressions. It provides powerful pattern-based renaming. The s/// substitution operator replaces text. Global flag g replaces all occurrences. Transliteration y/// transforms character sets. Useful for case changes. Perl code can use $_ for filename. Complex transformations are possible. Dry run shows what would happen. Always test patterns before applying. Multiple expressions chain transformations. Each -e adds another operation.

How do I run a basic prename example?

Run `prename 's/old/new/' [*.txt]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -n, --no-act do in prename?

Dry run, show changes.