1 个稳定版本
| 1.0.0 | 2024年4月16日 |
|---|
#2103 在 命令行工具
300KB
657 代码行
nomino
开发者使用的批量重命名工具

如何安装
预编译版
您可以下载适用于 Linux、MacOS 和 Windows 操作系统的预编译可执行文件,然后将该可执行文件复制到您的 $PATH 环境中
您可能需要运行 chmod +x nomino-linux-64bit 或 chmod +x nomino-macos-64bit.
Arch Linux
您可以使用 nominoAUR 软件包在 Arch Linux 中安装 nomino。
手动构建
如果您更喜欢手动构建 nomino,或者没有提供针对您的目标预编译的可执行文件,则可以从头开始构建 nomino
- 安装 Rust:
curl -sSf https://sh.rustup.rs | sh - 运行
cargo install nomino
使用方法
USAGE:
nomino [FLAGS] [OPTIONS] [[SOURCE] OUTPUT]...
FLAGS:
-e, --extension Preserves the extension of input files in 'sort' and 'regex' options
-h, --help Prints help information
-k, --mkdir Recursively creates all parent directories of '<OUTPUT>' if they are missing
-w, --overwrite Overwrites output files, otherwise, a '_' is prepended to filename
-p, --print Prints the map table to stdout
-t, --test Runs in test mode without renaming actual files (dry-run)
-V, --version Prints version information
OPTIONS:
--depth <DEPTH> Optional value to overwrite inferred subdirectory depth value in 'regex' mode
--max-depth <DEPTH> Optional value to set the maximum of subdirectory depth value in 'regex' mode
-d, --dir <PATH> Sets the working directory
-g, --generate <PATH> Stores a JSON map file in '<PATH>' after renaming files
-m, --map <PATH> Sets the path of map file to be used for renaming files
-r, --regex <PATTERN> Regex pattern (RE2 syntax) to match by filenames
-s, --sort <ORDER> Sets the order of natural sorting (by name) to rename files using enumerator [possible values: ASC, DESC]
ARGS:
<[SOURCE] OUTPUT>... OUTPUT is the pattern to be used for renaming files, and SOURCE is the optional regex pattern to match by filenames. SOURCE has the same function as -r option
映射文件格式
{
"<input1>": "<output1>",
"<input2>": "<output2>",
"<...>": "<...>"
}
输出
当使用 --sort 或 --regex 选项时,输出是必要的。
正则表达式
接受的正则表达式模式语法是 RE2.
占位符
- 占位符的格式为
{I:P},其中I是捕获组的索引,P是数字填充,用0填充。例如,{2:3}表示第三个捕获组,填充为 3,即1格式化为001。 - 索引从
0开始,{0}表示文件名。 - 索引
I可以省略,即{}或{:3}。在这种情况下,使用一个从1开始自动递增的索引。例如,{} {}等于{1} {2}。 - 可以使用
{和}字符进行转义,即 cli 中的\\{和\\}。 - 填充仅用于正数,例如,对
{:3}的1的格式化结果是001,对-1是-1,对a是a。 - 如果使用
--sort选项,第一个索引{0}是文件名,第二个索引{1}或第一个{}的出现是枚举索引。
Wiki
依赖项
~10-23MB
~349K SLoC