17 个版本 (8 个破坏性更新)
0.9.1 | 2024年3月11日 |
---|---|
0.8.2 | 2024年3月9日 |
0.4.1 | 2023年10月22日 |
161 在 命令行工具
每月下载量 758
34KB
571 行
GRU : G 重命名工具
用于在提供的目录中批量重命名文件的 命令行工具
主要功能
- 每次使用后生成备份文件
- 避免循环
- dry-run 标志以预览更改
- 检测并使用正确的填充数字
- 忽略/包含隐藏文件
- 随机排序
- 仅针对一个扩展名
- 在文件名末尾附加十六进制CRC32校验和
- 替换扩展名
- 替换字符串的n或所有出现
- 将Unicode转换为ASCII表示
- 所有基本功能,如清除原始名称、编号、添加前缀、删除n个...
- 支持Linux和Windows,也应在macOS上工作,但我无法测试
安装
- 使用 cargo :
cargo install rename-gru
- 或从源代码构建
git clone https://github.com/G1ya777/GRU && cd GRU
然后cargo build
- 在Arch Linux上,从AUR安装包
rename-gru-git
使用示例
- 示例文件树
├── audios
│ ├── hit.mp3
│ ├── other.mp3
│ ├── song.mp3
│ └── test.mp3
├── images
│ ├── image.png
│ ├── img1.png
│ ├── img2.png
│ └── otherimg.png
├── other
│ ├── data
│ │ └── somefile
│ ├── file
│ └── video.mp4
└── videos
├── file1.mkv
├── file2.mkv
├── file.mkv
└── other_video.mkv
rename-gru--clear--main-filename"- main -" --prefix"prefix" -suffix"- suffix" --numbering./other
data -------> prefix - main - 1 - suffix
file -------> prefix - main - 2 - suffix
video.mp4 -------> prefix - main - 3 - suffix.mp4
- 重命名视频文件,在末尾添加标签
rename-gru./videos--clear--prefix"MTVS" --numbering--suffix"[AWSMUploader] [1080P]""
file.mkv -------> MTVS1[AWSMUploader] [1080P].mkv
file1.mkv -------> MTVS2[AWSMUploader] [1080P].mkv
file2.mkv -------> MTVS3[AWSMUploader] [1080P].mkv
other_video.mkv -------> MTVS4[AWSMUploader] [1080P].mkv
- 重命名背景文件,使用随机排序
rename-gru./images--clear--prefix"bg" --numbering--sort-by3
image.png -------> bg1.png
img2.png -------> bg2.png
otherimg.png -------> bg3.png
img1.png -------> bg4.png
- 保留标题并在文件开头添加编号
rename-gru./images--main-filename" - " -B--numbering-b--sort-by3
image.png -------> 1 - image.png
otherimg.png -------> 2 - otherimg.png
img2.png -------> 3 - img2.png
img1.png -------> 4 - img1.png
- 仅重命名 .mp4 文件
rename-gru./other--clear--prefix"my_video" --numbering--sort-by3 -t".mp4"
video.mp4 -------> my_video1.mp4
- 仅重命名文件夹
rename-gru./other--only-folders-n
data -------> data1
- 在文件名末尾附加CRC32校验和
rename-gru--crc./videos
file.mkv -------> file [AA98C6D9].mkv
file1.mkv -------> file1 [26022818].mkv
file2.mkv -------> file2 [1B5BD171].mkv
other_video.mkv -------> other_video [23233DEC].mkv
- 恢复原始文件名
rename-gru./videos--restore"./videos/grubcp-2023-10-22-18-17-23.json"
使用方法
A CLI tool to batch rename files in the provided directory
Usage: rename-gru [OPTIONS] [LOCATION]
Arguments:
[LOCATION] location of the files to rename (defaults to the current location)
Options:
--restore <RESTORE>
-c, --clear
use if you wanna clear the original titles and start naming from scratch (the extension will be kept)
-p, --prefix <PREFIX>
Prefix to add for the naming
-s, --suffix <SUFFIX>
Suffix to add for the naming
-m, --main-filename <MAIN_FILENAME>
add a main filename (when --clear isn't used it is added after the original filename)
-B
add the main filename before the original filename when --clear isn't used
-n, --numbering
Add numbering
--pad <PAD>
specify padding for numbering, use --no-pad to disable (defaults to number of digits of number of files - 1)
--no-pad
-b, --before-main-name
numbering position, can be before main_filename or after main_filename (default)
--start <START>
custom numbering start (default is 1)
--crc
add crc32 checksum in hex at the end each filename (folders won't be renamed if this option is used)
--replace <Replace> <Replace_with>
replace old String with a new one
-e, --extension-replace-by <EXTENSION_REPLACE_BY>
replace the extension of the original title of all files with a new one (eg: .mp3) (also use -t to target files with a certain extension)
--sort-by <SORT_BY>
how to sort files, default is 0 (by name), 1 is by modification date, 2 for date created, 3 for random
--desc
set file sort to descending
--only-files
only modify files and don't modify folders
--only-folders
only modify folders and don't modify files
-f, --first-n-remove <FIRST_N_REMOVE>
remove the first n characters from the original title
-l, --last-n-remove <LAST_N_REMOVE>
remove the last n characters from the original title
-r, --remove-all <REMOVE_ALL>
remove all occurrences of a string from the original title
--remove-n <REMOVE_N>
remove n occurrences of a string (defaults to 1) from the original title (use --times to specify the number)
--times <TIMES>
use with remove_n to specify a number of occurrences to remove
-t, --target-extension <TARGET_EXTENSION>
apply renaming only to files ending with provided extension (eg : .jpg)
--no-bcp
disable backing up the original filenames
--no-temp-rename
disable temporary renaming (used to avoid cycles)
--incl-hidden
also rename hidden files (turn off by default)
--to-ascii
convert utf-8 to ascii
--dry-run
use to preview file names, w/o writing
--noconfirm
perform rename w/o asking for y/n
-h, --help
Print help
-V, --version
Print version
发现错误或想要新功能?
- 问题
- 任何帮助都将受到欢迎。
依赖关系
~3–15MB
~141K SLoC