くだすれPython(超初心者用) その4at TECH
くだすれPython(超初心者用) その4 - 暇つぶし2ch287:デフォルトの名無しさん
09/06/25 00:28:37
>>284
なんかいろいろまちがっててよくわからんけど
こうしたかったんじゃないか?

# -*- coding: utf-8 -*-

import os

targetpath = r"C:\test"

filelist = os.listdir(targetpath)

for filename in filelist:
    print filename

c = 1
for filename in filelist:
    oldpath = os.path.join(targetpath, filename)
    newpath = os.path.join(targetpath, '%03d.mp3' % c)
    os.rename(oldpath, newpath)
    c += 1



次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch