Skip to main content

A utility for finding files and directories

Project description

util-find

Python Version License: MIT PyPI Version

一个轻量级、高效的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.0.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.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: util_find-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for util_find-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2a4197ecb58c4c53040c534e1e5566cdde84bd89737e6f8661b118fc80db5a27
MD5 36aa5bd22e805cb3fdcd58cfaa0c86bd
BLAKE2b-256 694952b3f2c429e45d45ead0113e2baf0fe0e6ed653152d64116bb8092663f2e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: util_find-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for util_find-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 385d80d33f56c1a9f1400aa16b9600fb91203032a7918252fc804705baed363a
MD5 ca2509bc6d650a4fbe65af22e4c7a2d8
BLAKE2b-256 9aa955c134d107add9d4e4b75a9748465ce5e7c1da77df2e809bd31dbbfbb549

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