← 返回命令列表

Linux command

rename.util 命令

文本

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

常用示例

Example

rename [foo] [bar] *

Dry-run

rename -v -n [foo] [bar] *

Example

rename -o [foo] [bar] *

Example

rename .ext .bak *.ext

Prepend

rename '' '[prefix]' *

Zero-pad

rename foo foo00 foo? && rename foo foo0 foo??

说明

rename from util-linux performs batch file renaming using simple string substitution. It replaces the first occurrence of _expression_ with _replacement_ in each filename. Unlike the Perl rename command, it does not use regular expressions. The command processes all matching files, making it efficient for bulk operations like changing extensions or adding prefixes. Multiple rename operations can be chained together for more complex transformations.

参数

-v, --verbose
Show which files are being renamed
-n, --no-act
Dry run; show what would be renamed without doing it
-o, --no-overwrite
Do not overwrite existing files
-a, --all
Replace all occurrences, not just the first
-l, --last
Replace the last occurrence instead of the first
-s, --symlink
Rename symbolic link target instead of link itself
-i, --interactive
Prompt before overwriting
-V, --version
Display version information
-h, --help
Display help message

FAQ

What is the rename.util command used for?

rename from util-linux performs batch file renaming using simple string substitution. It replaces the first occurrence of _expression_ with _replacement_ in each filename. Unlike the Perl rename command, it does not use regular expressions. The command processes all matching files, making it efficient for bulk operations like changing extensions or adding prefixes. Multiple rename operations can be chained together for more complex transformations.

How do I run a basic rename.util example?

Run `rename [foo] [bar] *` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -v, --verbose do in rename.util?

Show which files are being renamed