#regex #tui #cli #终端 #文件重命名

程序+库 irename

交互式文件重命名工具

7 个版本

0.1.6 2022 年 8 月 18 日
0.1.5 2022 年 8 月 15 日

#20 in #文件重命名

MIT 许可证

24KB
515

irename

Crate API

交互式重命名工具

demo

安装

cargo install irename

用法

示例

重命名多个文件

# run renamer on all .txt files in some/dir
irename some/dir/*.txt

dry-run 模式执行

# run renamer on all .txt files in some/dir and only print generated commands w/o actual renaming
irename --dry-run some/dir/*.txt

dry-run 模式的输出可以管道传输

# generate rename commands and execute them by yourself
irename --dry-run some/dir/*.txt | parallel -n1

如果没有提供位置参数,则从 stdin 读取文件列表

# find files using your favorite tool (e.g. `fd`) and pipe the file list into renamer
fd \.rs | irename

备注:如果存在冲突的名称,应用程序将以错误退出。它不会像 GNU rename 那样破坏你的文件

Cli 帮助输出

USAGE:
    irename [OPTIONS] [FILES]...

ARGS:
    <FILES>...    files to rename. If none provided, the files list will be read from stdin

OPTIONS:
        --dry-run              only print shell commands w/o executing them
    -h, --help                 Print help information
        --regex <REGEX>        Initial regex
        --replace <REPLACE>    Initial replacement string
    -V, --version              Print version information

快捷键

  • Tab - 在 regexreplacement 文本输入区域之间切换
  • Enter - 执行重命名
  • Ctrl-c - 退出

待办事项

  • 如果没有提供位置参数,则从 stdin 读取输入文件路径
  • 帮助侧边栏
  • 匹配标志
  • 使用 Ctrl-d/Ctrl-u 滚动文件列表
  • 突出显示冲突名称
  • 全路径模式切换,编辑整个路径而不是仅文件名
  • 文档

依赖关系

~8–20MB
~229K SLoC