Skip to main content

Python iterate over path tree.

安装

你可以通过 pypi 安装

pip install -U iterdir

使用

用作模块

from iterdir import iterdir

用作命令

提供一个命令行工具,用于导出目录树

$ iterdir -h
usage: iterdir [-h] [-m MIN_DEPTH] [-M MAX_DEPTH]
               [-k [{inode,name,path,relpath,is_dir,stat,stat_info} ...]]
               [-s SELECT] [-se] [-o OUTPUT_FILE]
               [-hs [{shake_256,blake2b,blake2s,sha512_224,sha224,sha3_384,sha512,ripemd160,sm3,md5-sha1,sha3_256,sha3_224,sha256,sha1,sha384,sha3_512,shake_128,sha512_256,md5,crc32} ...]]
               [-dfs] [-fl] [-v]
               [path]

目录树信息遍历导出

positional arguments:
  path                  文件夹路径,默认为当前工作目录

options:
  -h, --help            show this help message and exit
  -m MIN_DEPTH, --min-depth MIN_DEPTH
                        最小深度,默认值 0,小于 0 时不限
  -M MAX_DEPTH, --max-depth MAX_DEPTH
                        最大深度,默认值 -1,小于 0 时不限
  -k [{inode,name,path,relpath,is_dir,stat,stat_info} ...], --keys [{inode,name,path,relpath,is_dir,stat,stat_info} ...]
                        选择输出的 key,默认输出所有可选值
  -s SELECT, --select SELECT
                        对路径进行筛选,提供一个表达式(会注入一个变量 entry,类型是 iterdir.DirEntry)或函数(会传入一个参数,类型是 iterdir.DirEntry)
  -se, --select-exec    对 -s/--select 传入的代码用 exec 运行,其中必须存在名为 select 的函数。否则,视为表达式或 lambda 函数
  -o OUTPUT_FILE, --output-file OUTPUT_FILE
                        保存到文件,此时命令行会输出进度条,根据扩展名来决定输出格式
                        - *.csv   输出一个 csv,第 1 行为表头,以后每行输出一条数据
                        - *.json  输出一个 JSON Object 的列表
                        - *       每行输出一条 JSON Object
  -hs [{shake_256,blake2b,blake2s,sha512_224,sha224,sha3_384,sha512,ripemd160,sm3,md5-sha1,sha3_256,sha3_224,sha256,sha1,sha384,sha3_512,shake_128,sha512_256,md5,crc32} ...], --hashes [{shake_256,blake2b,blake2s,sha512_224,sha224,sha3_384,sha512,ripemd160,sm3,md5-sha1,sha3_256,sha3_224,sha256,sha1,sha384,sha3_512,shake_128,sha512_256,md5,crc32} ...]
                        计算文件的哈希值,可以选择多个算法
  -dfs, --depth-first   使用深度优先搜索,否则使用广度优先
  -fl, --follow-symlinks
                        跟进符号连接,否则会把符号链接视为文件,即使它指向目录
  -v, --version         输出版本号

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iterdir-0.0.10.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iterdir-0.0.10-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file iterdir-0.0.10.tar.gz.

File metadata

  • Download URL: iterdir-0.0.10.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.5 Darwin/25.0.0

File hashes

Hashes for iterdir-0.0.10.tar.gz
Algorithm Hash digest
SHA256 e3e25c98eb8d8db97015cccacf2854aef9c1a9a55d8ee1bd8a9c6fbc1e13b17e
MD5 1049e1bc236495c7f7f0526c8925caa8
BLAKE2b-256 228e16832d8e319809dcc1e4cf6cd3354b32e3a421f324131c671b213a6c11ff

See more details on using hashes here.

File details

Details for the file iterdir-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: iterdir-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.13.5 Darwin/25.0.0

File hashes

Hashes for iterdir-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 26dc58d99adb2c859b0f94471348aa7daf1b5554b41e4c314508cdfaa278b24f
MD5 48930e38d1f684379ff8913fa0514050
BLAKE2b-256 607393f1e7194c1205bd842c12ee79afb21b465f6229395c4c098cbeef5f136f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7.1

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5.3

2 files

0.0.5.2

2 files

0.0.5.1

2 files

0.0.5

2 files

0.0.4.2

2 files

0.0.4.1

2 files

0.0.4

2 files

0.0.3.1

2 files

0.0.3

2 files

0.0.2.2

2 files

0.0.2.1

2 files

0.0.2

2 files

0.0.1

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page