Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pathlib import Path
- from opencc import OpenCC
- # converter of simplified chinese to traditional chinese
- converter = OpenCC("s2t")
- def convert_simplified_to_traditional(targetdir):
- for file in targetdir.glob("*"):
- if not file.is_dir():
- continue
- old_name = file.name
- new_name = converter.convert(old_name)
- if old_name == new_name:
- continue
- new_path = file.with_name(new_name)
- file.rename(new_path)
- print("Convert folder name from: {folder} to {new_path}")
- # rename the subfolder
- convert_simplified_to_traditional(new_path)
- def main():
- homedir = Path("D:\\Test")
- convert_simplified_to_traditional(homedir)
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement