Python program to traverse directories and read file information

后端 未结 3 2152
感动是毒
感动是毒 2021-02-19 16:23

I\'m just getting started with Python but already have found it much more productive than Bash shell scripting.

I\'m trying to write a Python script that will traverse e

3条回答
  •  情话喂你
    2021-02-19 17:15

    I'd use os.walk doing the following:

    def getInfos(currentDir):
        infos = []
        for root, dirs, files in os.walk(currentDir): # Walk directory tree
            for f in files:
                infos.append(FileInfo(f,root))
        return infos
    

提交回复
热议问题