指定したディレクトリ以下のファイルのリスト出力

暇だったので雑用ツールを作る。

python flist.py [ディレクトリ]

で実行。

  • flist.py
import sys
import os
import re

p = sys.argv[1]

count = 0
for root, dirs, files in os.walk(p):
  for d in dirs:
    # .svnディレクトリ以下は見ない
    if d == "\.svn":
      dirs.remove(d)
  for f in files:
    print os.path.join(root, f)
    count += 1
print count

★エラー処理してないので注意