Skip to main content

a simple package to get all files with given file extension in a directory

Project description

READ ME

This is a very simple package which simply gets all the files with extension matching a list of extensions in a given directory. I found that I was including functionality like this in so many other projects I might as well just make it a package. Plus I wanted to play with poetry.

install

pip install get_all_files

Examples

get all jpg files in home directory

from get_all_files import get_all_files
from pathlib import Path

home_dir = Path('~').expanduser()
jpg_files = get_all_files(home_dir, 'jpg')

get all jpg AND png files in home directory

from get_all_files import get_all_files
from pathlib import Path

home_dir = Path('~').expanduser()
jpg_files = get_all_files(home_dir, ['jpg', 'png'])

get absolute file paths instead of file names

from get_all_files import get_all_files
from pathlib import Path

home_dir = Path('~').expanduser()
jpg_files = get_all_files(home_dir, ['jpg', 'png'], return_absolute_filepath=True)

Loop over multiple directories

This package is not recursive - if you want to process multiple directories you have to do it yourself:

from get_all_files import get_all_files
from pathlib import Path
import os

home_dir = Path('~').expanduser()
subfolders = [f.path for f in os.scandir(home_dir) if f.is_dir()]
extension = 'txt'  # why not
all_files = []
for folder in subfolders:
    files = get_all_files(folder, extension, return_absolute_filepath=True)
    all_files.extend(files)

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

get_all_files-0.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

get_all_files-0.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file get_all_files-0.0.1.tar.gz.

File metadata

  • Download URL: get_all_files-0.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for get_all_files-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a0f7b5dc540ac1d4204e453613675b7e59258dbc9dc37f5551604031387e93d1
MD5 d5f84e787f5f409cf9c6f81e23f3edd9
BLAKE2b-256 1202402c299174225f8ab29f702d7e800e9b1d3202d39180a12787e8af1252eb

See more details on using hashes here.

File details

Details for the file get_all_files-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for get_all_files-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 28b9905f8a10f5414ca0f826546a86b3607c928a75901493f083c31f9522243d
MD5 a15f3ca495efc931a0d8a86137c9994e
BLAKE2b-256 e89358d97be025f6550ae9e732c008f07c02b68fb29b3011434b7139613ac8dd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page