LoginSignup
0
0

More than 1 year has passed since last update.

pathlibでディレクトリを再帰的に検索してファイルリストを表示する

Posted at

実行イメージ

image.png

ソース

get_file_list.py
# -*- cording: cp932 -*-
from pathlib import Path

def main():
    get_file_list()

def get_file_list():
    parent_path = "C:\\Windows\\boot"
    str_header = "ファイルパス"
    print(str_header)
    p = Path(parent_path)
    l = list(p.glob("**/*"))
    for element in l:
        if element.is_file():
            s_element = str(element)
            print(s_element)

if __name__ == "__main__":
    main()  

結果

ファイルパス
C:\Windows\boot\BootDebuggerFiles.ini
C:\Windows\boot\DVD\EFI\BCD
C:\Windows\boot\DVD\EFI\boot.sdi
(中略)
C:\Windows\boot\PCAT\zh-TW\memtest.exe.mui
C:\Windows\boot\Resources\bootres.dll
C:\Windows\boot\Resources\en-US\bootres.dll.mui
C:\Windows\boot\Resources\ja-JP\bootres.dll.mui
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0