-
Notifications
You must be signed in to change notification settings - Fork 20
Examples
Navid edited this page Apr 19, 2021
·
12 revisions
Consider the following directory:
➜ ls
Nomino (2020) S1.E1.1080p.mkv
Nomino (2020) S1.E2.1080p.mkv
Nomino (2020) S1.E3.1080p.mkv
Nomino (2020) S1.E4.1080p.mkv
Nomino (2020) S1.E5.1080p.mkv
Note that -p
flag is used to print the table and -e
flag is used to preserve the extension of input.
- Rename files using
regex
option (-r
is optional and can be omitted):
➜ nomino -p ".* S(\d+).E(\d+).*.(mkv)" "S{:2}E{:2}.{}"
+-------------------------------+------------+
| Input | Output |
+-------------------------------+------------+
| Nomino (2020) S1.E1.1080p.mkv | S01E01.mkv |
| Nomino (2020) S1.E2.1080p.mkv | S01E02.mkv |
| Nomino (2020) S1.E3.1080p.mkv | S01E03.mkv |
| Nomino (2020) S1.E4.1080p.mkv | S01E04.mkv |
| Nomino (2020) S1.E5.1080p.mkv | S01E05.mkv |
+-------------------------------+------------+
➜ nomino -pr ".* S(\d+).E(\d+).*.(mkv)" "S{:2}E{:2}.{}"
+-------------------------------+------------+
| Input | Output |
+-------------------------------+------------+
| Nomino (2020) S1.E1.1080p.mkv | S01E01.mkv |
| Nomino (2020) S1.E2.1080p.mkv | S01E02.mkv |
| Nomino (2020) S1.E3.1080p.mkv | S01E03.mkv |
| Nomino (2020) S1.E4.1080p.mkv | S01E04.mkv |
| Nomino (2020) S1.E5.1080p.mkv | S01E05.mkv |
+-------------------------------+------------+
- Rename files using
sort
option:
➜ nomino -pes asc "{:3}"
+-------------------------------+---------+
| Input | Output |
+-------------------------------+---------+
| Nomino (2020) S1.E1.1080p.mkv | 001.mkv |
| Nomino (2020) S1.E2.1080p.mkv | 002.mkv |
| Nomino (2020) S1.E3.1080p.mkv | 003.mkv |
| Nomino (2020) S1.E4.1080p.mkv | 004.mkv |
| Nomino (2020) S1.E5.1080p.mkv | 005.mkv |
+-------------------------------+---------+
➜ nomino -pes desc "{:3}"
+-------------------------------+----------+
| Input | Output |
+-------------------------------+----------+
| Nomino (2020) S1.E5.1080p.mkv | 001.mkv |
| Nomino (2020) S1.E4.1080p.mkv | 002.mkv |
| Nomino (2020) S1.E3.1080p.mkv | 003.mkv |
| Nomino (2020) S1.E2.1080p.mkv | 004.mkv |
| Nomino (2020) S1.E1.1080p.mkv | 005.mkv |
+-------------------------------+----------+
- Rename files using the following
map.json
file:
{
"Nomino (2020) S1.E1.1080p.mkv": "0101.mkv",
"Nomino (2020) S1.E2.1080p.mkv": "0102.mkv",
"Nomino (2020) S1.E3.1080p.mkv": "0103.mkv",
"Nomino (2020) S1.E4.1080p.mkv": "0104.mkv",
"Nomino (2020) S1.E5.1080p.mkv": "0105.mkv"
}
➜ nomino -pm map.json
+-------------------------------+----------+
| Input | Output |
+-------------------------------+----------+
| Nomino (2020) S1.E1.1080p.mkv | 0101.mkv |
| Nomino (2020) S1.E2.1080p.mkv | 0102.mkv |
| Nomino (2020) S1.E3.1080p.mkv | 0103.mkv |
| Nomino (2020) S1.E4.1080p.mkv | 0104.mkv |
| Nomino (2020) S1.E5.1080p.mkv | 0105.mkv |
+-------------------------------+----------+
rename files by creating a map file using -g
option, then use that map file to undo renaming:
➜ nomino -g undo.json -pr ".*.(mkv)" "a.{}"
+-------------------------------+-----------+
| Input | Output |
+-------------------------------+-----------+
| Nomino (2020) S1.E1.1080p.mkv | ____a.mkv |
| Nomino (2020) S1.E4.1080p.mkv | ___a.mkv |
| Nomino (2020) S1.E3.1080p.mkv | __a.mkv |
| Nomino (2020) S1.E2.1080p.mkv | _a.mkv |
| Nomino (2020) S1.E5.1080p.mkv | a.mkv |
+-------------------------------+-----------+
➜ nomino -pm undo.json
+-----------+-------------------------------+
| Input | Output |
+-----------+-------------------------------+
| ____a.mkv | Nomino (2020) S1.E1.1080p.mkv |
| _a.mkv | Nomino (2020) S1.E2.1080p.mkv |
| __a.mkv | Nomino (2020) S1.E3.1080p.mkv |
| ___a.mkv | Nomino (2020) S1.E4.1080p.mkv |
| a.mkv | Nomino (2020) S1.E5.1080p.mkv |
+-----------+-------------------------------+
Consider the following tree:
➜ tree
.
├── s1
│ ├── Nomino (2020) S1.E1.1080p.mkv
│ ├── Nomino (2020) S1.E2.1080p.mkv
│ └── Nomino (2020) S1.E3.1080p.mkv
└── s2
├── Nomino (2020) S2.E1.1080p.mkv
├── Nomino (2020) S2.E2.1080p.mkv
├── Nomino (2020) S2.E3.1080p.mkv
└── Nomino (2020) S2.E4.1080p.mkv
- Read files from sub-directories, then create new sub-directories using
-k
flag, and rename files. Note that the sub-directory depth is inferred using the number of filename separators (i.e./
in Unix and\
in Windows) inregex
pattern which could be overwritten using--depth
argument.
➜ nomino -kpr "s(\d+)/.*E(\d+).*" "Season {:2}/Episode {:2}.mkv"
+----------------------------------+--------------------------+
| Input | Output |
+----------------------------------+--------------------------+
| s1/Nomino (2020) S1.E1.1080p.mkv | Season 01/Episode 01.mkv |
| s1/Nomino (2020) S1.E2.1080p.mkv | Season 01/Episode 02.mkv |
| s1/Nomino (2020) S1.E3.1080p.mkv | Season 01/Episode 03.mkv |
| s2/Nomino (2020) S2.E1.1080p.mkv | Season 02/Episode 01.mkv |
| s2/Nomino (2020) S2.E2.1080p.mkv | Season 02/Episode 02.mkv |
| s2/Nomino (2020) S2.E3.1080p.mkv | Season 02/Episode 03.mkv |
| s2/Nomino (2020) S2.E4.1080p.mkv | Season 02/Episode 04.mkv |
+----------------------------------+--------------------------+
➜ nomino --depth 2 -kpr "s(\d+)/.*E(\d+).*" "Season {:2}/Episode {:2}.mkv"
+----------------------------------+--------------------------+
| Input | Output |
+----------------------------------+--------------------------+
| s1/Nomino (2020) S1.E1.1080p.mkv | Season 01/Episode 01.mkv |
| s1/Nomino (2020) S1.E2.1080p.mkv | Season 01/Episode 02.mkv |
| s1/Nomino (2020) S1.E3.1080p.mkv | Season 01/Episode 03.mkv |
| s2/Nomino (2020) S2.E1.1080p.mkv | Season 02/Episode 01.mkv |
| s2/Nomino (2020) S2.E2.1080p.mkv | Season 02/Episode 02.mkv |
| s2/Nomino (2020) S2.E3.1080p.mkv | Season 02/Episode 03.mkv |
| s2/Nomino (2020) S2.E4.1080p.mkv | Season 02/Episode 04.mkv |
+----------------------------------+--------------------------+