Created
September 10, 2018 11:45
-
-
Save gitleej/853c6eec9e449ea1087f3287eb4a7098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Mon Sep 10 10:07:16 2018 | |
@author: Administrator | |
""" | |
# 导入必要的包 | |
import os | |
import pandas as pd | |
PATH = ".\\" | |
fileCount = 0 | |
dirCount = 0 | |
for x, _, _ in os.walk(os.path.dirname(PATH)): | |
if len(x) != 0: | |
fileCount = 0 | |
dirCount = 0 | |
paths = os.listdir(x) | |
for path in paths: | |
path = os.path.sep.join([x, path]) | |
if os.path.isdir(path): | |
dirCount += 1 | |
elif os.path.isfile(path): | |
fileCount += 1 | |
print(x) | |
print("\tfiles: {}".format(fileCount)) | |
print("\tdirs: {}".format(dirCount)) | |
fileList=[] | |
for root, dirs, files in os.walk(PATH): | |
fileList.append([]) | |
fileList[-1].append(root) | |
for file in files: | |
fileList[-1].append(file) | |
csvFileList = pd.DataFrame(fileList) | |
csvFileList.to_csv("filelist.csv") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment