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.3.0.tar.gz (2.8 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.3.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fileutils_dir-0.3.0.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

Hashes for fileutils_dir-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0ddfb8bb12500f4bdc34e915e1d55b1ca3191bd402929e1fbbf7bba9d2af6037
MD5 7a783194ec02dd46f67ec4dfa5fc8eed
BLAKE2b-256 2aaf01213890592bd3e18d4e9052b2517086997b30fca472d604bbe87bdd602f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fileutils_dir-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 3.1 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1baf7c98496888816a42b14f220487106e23205c4370db0ab538920e49faf099
MD5 aec537ae60d59edbd58071d88b3eba4f
BLAKE2b-256 be616f074b30a0fa257f536a29127ff80aee090f34089ce640802ab15ae817b7

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