Export directory or file tree list, Python generates folder or file tree list.

First of all this is a sad story, one of my hard disks was broken... Then I forgot what was in the hard disk, so I wrote a small script to generate the directory listing, part of the code came from the Internet, but the version on the Internet had some problems, so I rewrote it based on this.

git address

Export directory or file tree list

export pretty and readable directory or file tree list.

from directoryTree import DirectoryTree

if __name__ == '__main__':
    ignore_list = ('.git', '$RECYCLE.BIN', '.svn', 'System Volume Information', '.sync', '.idea')
    tree = DirectoryTree(ignore_list=ignore_list, directory_path=r'E:\CloudMusic\Aimer')
    print('==================FileTree==================')
    print(tree.tree)
    print('==================DirTree==================')
    print(tree.dir_tree)
==================FileTree==================
E:/CloudMusic/Aimer/
├────E:/CloudMusic/Aimer/After Dark/
│    └────E:/CloudMusic/Aimer/After Dark/Aimer - 六等星の夜 (from Live at anywhere).ncm
├────E:/CloudMusic/Aimer/broKen NIGHT / holLow wORlD/
│    └────E:/CloudMusic/Aimer/broKen NIGHT / holLow wORlD/Aimer - my sweetest one.flac
├────E:/CloudMusic/Aimer/DAWN/
│    └────E:/CloudMusic/Aimer/DAWN/Aimer - LAST STARDUST.flac
├────E:/CloudMusic/Aimer/Daydream/
│    └────E:/CloudMusic/Aimer/Daydream/Aimer - カタオモイ.ncm
├────E:/CloudMusic/Aimer/Ref:rain (期間生産限定盤)/
│    └────E:/CloudMusic/Aimer/Ref:rain (期間生産限定盤)/Aimer - Ref:rain.ncm
└────E:/CloudMusic/Aimer/茜さす/everlasting snow/
│    └────E:/CloudMusic/Aimer/茜さす/everlasting snow/Aimer - 茜さす.ncm

==================DirTree==================
E:/CloudMusic/Aimer/
├────E:/CloudMusic/Aimer/After Dark/
├────E:/CloudMusic/Aimer/broKen NIGHT / holLow wORlD/
├────E:/CloudMusic/Aimer/DAWN/
├────E:/CloudMusic/Aimer/Daydream/
├────E:/CloudMusic/Aimer/Ref:rain (期間生産限定盤)/
└────E:/CloudMusic/Aimer/茜さす/everlasting snow/

Guess you like

Origin blog.csdn.net/zxsean/article/details/109676988