LoginSignup
0
0

More than 3 years have passed since last update.

ファイルリネームを簡単に実施する方法

Posted at

ファイルのリネームは業務で必要とされる機会は意外と頻度が高いように感じたため、備忘録として記載する。

import os
import glob

N = 8 #YYYYMMDDをファイル名から削除する場合は8文字の削除
EXT = "*.txt"
DIR = r"C:\Users\dirname" #ファイルパスの接頭辞「r」は不要な場合もある。

os.chdir(DIR)
for file in glob.glob(EXT):
    os.rename(file,file[N:])
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