Skip to main content

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 str or pathlib.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 .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


Download files

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

Source Distribution

fileutils_dir-0.2.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

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

fileutils_dir-0.2.0-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file fileutils_dir-0.2.0.tar.gz.

File metadata

  • Download URL: fileutils_dir-0.2.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fileutils_dir-0.2.0.tar.gz
Algorithm Hash digest
SHA256 da714fc90810d0fec260f7852e03c66d162d7de2a8d6b6c053e0ba948cc20c50
MD5 9f4205712fe0cbfac550fef6f907b1d2
BLAKE2b-256 397c4a8a0c1b43647dcef83844c5b1779ffa0d5a6180180928f16c35305ee390

See more details on using hashes here.

File details

Details for the file fileutils_dir-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fileutils_dir-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for fileutils_dir-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93975ec552328c709b315c9317f50e154a407b562352635a601df9c0b6676c06
MD5 c9e346373c86ffc2eac0e4cede3023aa
BLAKE2b-256 7ed61012154a28abf3bdb7cc42941b781ea269a3f8690da41818864d74ce7db9

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