2010年9月7日火曜日

ファイル名前変更 Python

現在ディレクトリを読んでファイル名を変更するプログラム。
f[4:]という書き方が面白い。

import os, sys
from stat import *
import shutil
for f in os.listdir(os.getcwd()):
if os.path.isfile(f) == True:
shutil.move(f,'2009'+f[4:])
view raw rename.py hosted with ❤ by GitHub

0 件のコメント: