0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Python】フォルダ内のファイルの末尾に文字列を一括追加する

Posted at
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)
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?