#!/usr/bin/env python # -*- coding: utf-8 -*- # # txtファイルをe621ファイルに変換する # Convert txt files to e621 files import os from pathlib import Path def rename_txt_to_e621(target_dir='.'): for root, dirs, files in os.walk(target_dir): for file in files: if file.endswith('.txt'): txt_file = Path(root) / file e621_file = txt_file.with_suffix('.e621') os.rename(txt_file, e621_file) print(f"Renamed {txt_file} to {e621_file}") if __name__ == '__main__': target_directory = input('Enter the target directory (leave blank for current directory): ') if not target_directory: target_directory = '.' rename_txt_to_e621(target_directory)