Handlers#
BasicHandler
#
Basic file name manipulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method |
str
|
Specify how to modify the file name. Accepted values are
( |
required |
value |
str
|
Value to add or remove from the file name. |
required |
Source code in renameit/handlers/basic.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
DateTimeHandler
#
Add datetime values to file names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt_value |
str
|
Specify where to get date & time values from:
|
required |
dt_format |
str
|
How to format the |
required |
add_as |
str
|
Where to add |
required |
Source code in renameit/handlers/datetime.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
RegexHandler
#
Manipulate file paths using regular expressions.
It works by using matching pattern with named groups and then using those groups into a replacement string template passed on to the re.sub method.
Example:
match_pattern = r"(?P<year>\d+)/(?P<month>\d+)/(?P<day>\d+)/(?P<file_name>.*)".
replace_pattern = "year=\g<year>/month=\g<month>/day=\g<day>/\g<file_name>".
transforms "2022/01/01/file1.csv" to "year=2022/month=01/day=01/file1.csv".
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
match_pattern |
str
|
Regular expressiong with named capturing groups. |
required |
replace_pattern |
str
|
String that contains the named replacement syntax for the caught named groups if there is a match. |
required |
case_sensitive |
bool
|
Applies case sensitive matching. Defaults to True. |
True
|
Source code in renameit/handlers/regex.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |