toolkit / utils /txt2tags.py
k4d3's picture
chmod
fea0c98
raw
history blame
762 Bytes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# txtファイルを.tagsファイルに変換する
# Convert txt files to .tags files
import os
from pathlib import Path
def rename_txt_to_tags(target_dir='.'):
for root, _, files in os.walk(target_dir):
for file in files:
if file.endswith('.txt'):
txt_file = Path(root) / file
tags_file = txt_file.with_suffix('.tags')
os.rename(txt_file, tags_file)
print(f"Renamed {txt_file} to {tags_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_tags(target_directory)