A utility for finding files and directories
Project description
util-find
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
主要改进点:
- 添加了PyPI版本徽章
- 使用emoji图标增强可读性
- 完善了功能特性描述
- 添加了更实用的代码示例
- 规范了API文档格式
- 细化了贡献指南
- 优化了整体排版和可读性
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6238c124993e47057de941bcb4b7a77e8ddd31ae82792e4622b9f3054d7079e
|
|
| MD5 |
373a2b70a8f0282840aa2de40c814000
|
|
| BLAKE2b-256 |
e9ad2b19523942c78c1fc069ae9e59b737abf6afc6d682f9012e3bc49a557710
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6290393107aaf1b10f1947a5fe774dd45bec47a46cc8c73559bd9477c687ea42
|
|
| MD5 |
b93744dce7fd60916095212d800af4ac
|
|
| BLAKE2b-256 |
781a476e73ad59888468fedd307dbbf0608cf6efcb4ed2482e4591b9d07e9ded
|