Default38693 commited on
Commit
c9ef50a
·
1 Parent(s): 0a843a7

Delete file_renamer.py

Browse files
Files changed (1) hide show
  1. file_renamer.py +0 -22
file_renamer.py DELETED
@@ -1,22 +0,0 @@
1
- import hashlib
2
- from pathlib import Path
3
-
4
- #指定ディレクトリのpngファイル名をmd5に変更するやつ。全角とかスペースの考慮がだるいときに
5
-
6
- def md5_hash(file_path):
7
- with open(file_path, 'rb') as f:
8
- file_data = f.read()
9
- md5_hash = hashlib.md5(file_data).hexdigest()
10
- return md5_hash
11
-
12
- def rename_files_in_directory(directory_path):
13
- dir_path = Path(directory_path)
14
- for file_path in dir_path.glob('*.png'):
15
- new_file_name = md5_hash(file_path) + ".png"
16
- new_file_path = file_path.parent / new_file_name
17
- file_path.rename(new_file_path)
18
- print(f"Renamed {file_path} to {new_file_path}")
19
-
20
- if __name__ == "__main__":
21
- directory_path = r"E:\Dataset\XXXXXXX" # ここにディレクトリへのパスを入力してください
22
- rename_files_in_directory(directory_path)