Python関連
891 ワード
一、pipバージョンの更新
二、フォルダの下のファイルに一括して名前を付ける
ファイル接尾辞を表示
Pythonファイルの実行
python -m pip install -U pip
二、フォルダの下のファイルに一括して名前を付ける
# coding:utf-8
import os
def rename():
count = 1
path = r'C:\Users\daile\Desktop\T'
filelist = os.listdir(path) # ( )
for files in filelist: #
if count < 10:
num = '0' + str(count)
else:
num = str(count)
Olddir = os.path.join(path, files) #
if os.path.isdir(Olddir): #
continue
filetype = os.path.splitext(files)[1] #
Newdir = os.path.join(path, num + filetype) #
os.rename(Olddir, Newdir) #
count += 1
rename()
ファイル接尾辞を表示
------ ------ ----
Pythonファイルの実行
python C:\Users\daile\Desktop\rename.py