Skip to main content

A utility for finding files and directories

Project description

util-find

Python Version License: MIT PyPI Version

git: https://gitee.com/mpypi/util-find

一个轻量级、高效的Python工具,用于递归查找文件和目录。

✨ 功能特性

  • 🔍 递归查找文件和目录
  • ⚡ 使用生成器实现,内存占用低
  • 🔗 可选是否跟踪符号链接
  • 📁 返回绝对路径列表
  • 🚀 纯Python实现,无额外依赖

🛠 安装

使用pip安装最新版本:

pip install --upgrade util-find

🚀 快速开始

from ufind import files, dirs

# 查找目录下所有文件
filenames = files('/home/user/Documents')

# 查找目录下所有pdf文件
pdf_files = [f for f in files('~/Documents') if f.endswith('.pdf')]
print(f"找到 {len(pdf_files)} 个PDF文件")

## 查找目录下所有子目录(包括符号链接)
project_dirs = dirs('/projects', followlinks=True)
print(f"项目目录包含 {len(project_dirs)} 个子目录")

递归获取指定路径下的所有文件

参数:

path (str): 要搜索的根路径(支持~表示家目录)

followlinks (bool): 是否跟踪符号链接,默认False

返回:

文件绝对路径列表(List[str])

递归获取指定路径下的所有目录

参数:

path (str): 要搜索的根路径(支持~表示家目录) followlinks (bool): 是否跟踪符号链接,默认False 返回:

目录绝对路径列表(List[str]) 示例:

# 查找所有隐藏目录
hidden_dirs = [d for d in dirs('~') if os.path.basename(d).startswith('.')]

📜 许可证 MIT License © 2023 birds

plainText

主要改进点:

  1. 添加了PyPI版本徽章
  2. 使用emoji图标增强可读性
  3. 完善了功能特性描述
  4. 添加了更实用的代码示例
  5. 规范了API文档格式
  6. 细化了贡献指南
  7. 优化了整体排版和可读性

Project details


Download files

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

Source Distribution

util_find-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

util_find-0.1.2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file util_find-0.1.2.tar.gz.

File metadata

  • Download URL: util_find-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for util_find-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f6238c124993e47057de941bcb4b7a77e8ddd31ae82792e4622b9f3054d7079e
MD5 373a2b70a8f0282840aa2de40c814000
BLAKE2b-256 e9ad2b19523942c78c1fc069ae9e59b737abf6afc6d682f9012e3bc49a557710

See more details on using hashes here.

File details

Details for the file util_find-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: util_find-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.7

File hashes

Hashes for util_find-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6290393107aaf1b10f1947a5fe774dd45bec47a46cc8c73559bd9477c687ea42
MD5 b93744dce7fd60916095212d800af4ac
BLAKE2b-256 781a476e73ad59888468fedd307dbbf0608cf6efcb4ed2482e4591b9d07e9ded

See more details on using hashes here.

Supported by

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