23 个版本 (11 个稳定版)
| 1.3.5 | 2024年6月6日 |
|---|---|
| 1.3.3 | 2023年10月29日 |
| 1.3.1 | 2022年12月30日 |
| 1.2.2 | 2022年8月12日 |
| 0.4.2 | 2020年4月23日 |
#242 在 命令行工具
每月26次下载
295KB
657 行
nomino
开发者批量重命名工具

如何安装
预编译版本
您可以下载适用于 Linux、MacOS 和 Windows 操作系统的预编译可执行文件,然后将该可执行文件复制到您的 $PATH 环境中
您可能需要运行 chmod +x nomino-linux-64bit 或 chmod +x nomino-macos-64bit。
手动构建
如果您想手动构建 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
依赖
~6–15MB
~167K SLoC