Small utilities for listing files in directories
Project description
fileutils
A small Python library for filtering and listing files.
Installation
pip install fileutils-dir
Usage
from fileutils import in_dir
# List all files in the current directory
files = in_dir()
# Filter by extension
python_files = in_dir(ext=[".py"])
# Filter by predefined categories
media_files = in_dir(dtype=["image", "video"])
# Filter by both
results = in_dir(path="src", ext=[".c"], dtype=["text"])
API Reference
in_dir(path=".", *, ext=None, dtype=None)
Returns a list of file paths as strings from the specified directory.
- path: Directory to search. Accepts
strorpathlib.Path. Defaults to".". - ext: An iterable of file extensions to include.
- dtype: An iterable of predefined file type categories.
If neither ext nor dtype are provided, all files in the directory are returned. If both are provided, the result is the union of both filters. Subdirectories are ignored.
Supported Types
The dtype parameter supports the following categories:
| Category | Extensions |
|---|---|
image |
.jpg, .jpeg, .png, .webp, .bmp, .gif, .tiff |
text |
.txt, .md, .rst, .log |
pdf |
|
doc |
.doc, .docx, .odt |
sheet |
.xls, .xlsx, .ods, .csv |
presentation |
.ppt, .pptx, .odp |
code |
.py, .js, .ts, .java, .c, .cpp, .h, .go, .rs, .rb, .php, .sh |
data |
.json, .yaml, .yml, .xml, .toml |
audio |
.mp3, .wav, .flac, .ogg, .aac, .m4a |
video |
.mp4, .mkv, .avi, .mov, .webm |
archive |
.zip, .tar, .gz, .bz2, .7z, .rar |
License
MIT
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 fileutils_dir-0.3.5.tar.gz.
File metadata
- Download URL: fileutils_dir-0.3.5.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b71057a14e559723e8ed86ab906f528badeeb9317947297eae20c952614793b1
|
|
| MD5 |
60c78d2edc21db46f2d25d2365671a80
|
|
| BLAKE2b-256 |
d23f93f0c771d4fabdb484ea70709362db5541011028cd1c95b877abb6cfe3b5
|
File details
Details for the file fileutils_dir-0.3.5-py3-none-any.whl.
File metadata
- Download URL: fileutils_dir-0.3.5-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
997f2a44f22e2aa86c1d709fbea9c30dfc901d23e13a5b71b5fa0383a0d6c949
|
|
| MD5 |
a6d4945abf55bd9cd2a889298235ea3d
|
|
| BLAKE2b-256 |
f37fab66e53cb45cb6d1edf166dfb91201f94ba5f012b1cf9eb27acc2fb84fa0
|