-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.py
More file actions
36 lines (28 loc) · 930 Bytes
/
Copy pathtree.py
File metadata and controls
36 lines (28 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import mimetypes
# files = os.listdir("./")
# file一覧出力 再帰関数
def output_files(file_path):
# TODO /のチェックと調整
# ファイル一覧を取得
files = os.listdir(file_path)
# ファイル一覧でループ
for file_name in files:
# pathを取得
child_file_path = file_path + '/' + file_name
# ファイル・タイプを取得
# file_type = mimetypes.guess_type(file_path)
# print(file_type)
# ディレクトリかどうか
if is_dir(child_file_path):
# ディレクトリの場合は再帰
output_files(child_file_path)
else:
# 通常ファイルの場合
print('node: ' + file_path)
print(file_name)
print(child_file_path)
print('-')
def is_dir(file_path):
return os.path.isdir(file_path)
output_files(".")