rmv: Renaming made easy with regex
Go to file
Pedro de Oliveira 3c083334a8 Join replace_extra_tags with replace_name to create replace_name_with_tags.
Removed every unwrap() functions now return a Result.
Used chatgpt to help me with the to_str() function.
2023-05-12 00:07:02 +01:00
src Join replace_extra_tags with replace_name to create replace_name_with_tags. 2023-05-12 00:07:02 +01:00
.gitignore First commit. WIP, just prints the mv command. Untested. 2023-05-07 20:01:12 +01:00
Cargo.lock First commit. WIP, just prints the mv command. Untested. 2023-05-07 20:01:12 +01:00
Cargo.toml Add README.md and LICENSE. 2023-05-07 20:18:13 +01:00
LICENSE Add README.md and LICENSE. 2023-05-07 20:18:13 +01:00
README.md Mention that currently only works in preview-mode. 2023-05-11 20:21:21 +01:00

README.md

rmv: Renaming made easy with regex

rmv is a command-line tool that allows you to rename files in a directory using regular expressions. You can use it to match patterns in file names and replace them with new patterns.

NOTE

Please note that rmv currently operates in preview mode, which means it will only display the command that should be executed to rename files using the specified regular expression patterns. This preview mode does not actually rename any files, so you will need to manually execute the generated commands to perform the desired renames.

Installation

To install rmv, Rust needs to be installed. Once Rust is installed, run the following command:

cargo install --git https://git.deadbsd.org/falso/rmv.git

Usage

To use rmv, you need to specify the path to the directory where the files to be renamed are located, a regular expression pattern to match against the file names, and a replacement pattern for the matched file names.

rmv --path <PATH> --pattern <PATTERN> --replacement <REPLACEMENT> [--wildcard <WILDCARD>]

--path

The --path argument specifies the path to the directory where the files to be renamed are located. This argument is required.

--pattern

The --pattern argument specifies the regular expression pattern to match against the file names. This argument is required.

You can use matching groups in the pattern to capture parts of the file name that you want to use in the replacement pattern. For example, the pattern "S(\d+)E(\d+)" will match on "S01E23" and capture "01" in group 1 and "23" in group 2.

--replacement

The --replacement argument specifies the replacement pattern for the matched file names. This argument is required.

You can use the following tags in the replacement pattern:

  • {full_name} - file name with extension
  • {name} - file name without extension
  • {ext} - extension
  • {1}, {2}, etc. to reference the match groups in the search pattern.

For example, if you have a pattern "S(\d+)E(\d+)" that matches "S01E11" and you want to replace it with "Season 01 Episode 11", you can use the following replacement pattern: "Season {1} Episode {2}.{ext}".

--wildcard (optional)

The --wildcard argument specifies a wildcard pattern to filter which files in the directory are considered. Only files whose names match the wildcard will be renamed. The default value is "*".

For example, if you want to only rename files with the .mkv extension, you can use the wildcard pattern "*.mkv".

Example

$ rmv --path /path/to/files --pattern "S(\d+)E(\d+)" --replacement "Season {1} Episode {2}.{ext}" --wildcard "*.mkv"

This will match all file names in the directory that match the pattern "S(\d+)E(\d+)" and replace them with the pattern "Season {1} Episode {2}.{ext}". Only files with the ".mkv" extension will be considered.

mv "Not Warez - S01E16 - HDTV-720p.mkv" "Season 01 Episode 16.mkv"
mv "Not Warez - S01E17 - HDTV-720p.mkv" "Season 01 Episode 17.mkv"
mv "Not Warez - S01E18 - HDTV-720p.mkv" "Season 01 Episode 18.mkv"
mv "Not Warez - S01E19 - HDTV-720p.mkv" "Season 01 Episode 19.mkv"
mv "Not Warez - S01E20 - WEBDL-1080p.mkv" "Season 01 Episode 20.mkv"
mv "Not Warez - S01E21 - WEBDL-1080p.mkv" "Season 01 Episode 21.mkv"

License

This tool is licensed under the WTFPL. See the LICENSE file for details.