Update README.md, new filename formatting

Signed-off-by: Lev Rusanov <30170278+JDM170@users.noreply.github.com>
This commit is contained in:
2024-05-14 00:14:44 +07:00
parent f518a75bc8
commit 98f6595e93
2 changed files with 7 additions and 3 deletions

View File

@@ -1 +1,4 @@
# renaname anilibria episodes # renaname anilibria episodes
Requirements to run:
- Python 3 (any version)

View File

@@ -20,10 +20,11 @@ def rename_file(current_name, splitted, settedPath):
if found_number is None: if found_number is None:
continue continue
found_number = found_number.group()[ pattern[1]:pattern[2] ] found_number = found_number.group()[ pattern[1]:pattern[2] ]
new_name = "{:02d}{}".format(int(found_number), splitted[1]) # Новое имя файла
current_path = "{}\\{}".format(settedPath, current_name) if settedPath is not None else realpath(current_name) # Получаем путь до файла current_path = "{}\\{}".format(settedPath, current_name) if settedPath is not None else realpath(current_name) # Получаем путь до файла
new_path = "{}{}{}".format(current_path.replace(current_name, ""), found_number, splitted[1]) # Новый путь до файла new_path = "{}{}".format(current_path.replace(current_name, ""), new_name) # Новый путь до файла
rename(current_path, new_path) # Переименовываем файл rename(current_path, new_path) # Переименовываем файл
print("\"{}\" successfully renamed to \"{}\".".format(current_name, found_number + splitted[1])) print("\"{}\" successfully renamed to \"{}\".".format(current_name, new_name))
def main(folder): def main(folder):