import os
folder_path = r'対象のディレクトリパス'
suffix = '追加したい文字列'
for filename in os.listdir(folder_path):
if not filename.lower().endswith(suffix):
old_path = os.path.join(folder_path, filename)
new_path = os.path.join(folder_path, filename + suffix)
os.rename(old_path, new_path)
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme