Skip to main content

Package for directories, files & paths management utilities.

Project description

License: MIT Generic badge Downloads

File Management Utilities (fmutils)

For easily accessing and managing large number of files and dirs in ML datasets.

Implemented Functions

class DirectoryTree generator. source

generates a dir tree displaying the full structure of the root dir, showing all the sub-dirs and the files.

Parameters:
  • root_dir – absolute/relative path to root directory containing all files.
  • dir_only – whether to only show sub-dirs in the dir-tree (excluding the files inside of each dir and sub-dir, good for getting an overview of large databases). The default is False.
  • write_tree – write the full dir-tree in a txt file in current working dir. The default is True.
Returns:

  • None.
  • get_all_files(main_dir, sort=True) source

    returns the list of all files inside the root dir.

    Parameters:
    • main_dir – absolute/relative path to root directory containing all files.
    • sort – wether to sort the output lost in Alphabetical order.
    Returns:

  • list containing full paths of all files..
  • get_all_dirs(main_dir, sort=True) source

    returns the list of all the sub-dirs inside the root dir.

    Parameters:
    • main_dir – absolute/relative path to root directory containing all files.
    • sort – wether to sort the output lost in Alphabetical order.
    Returns:

  • list containing full paths of all sub directories in root.
  • get_num_of_files(main_dir) source

    counts the number of files inside each sub-dir of the root.

    Parameters:
    • main_dir – absolute/relative path to root directory containing all files.
    Returns:

  • num_per_class – an array containing number of file in all sub dirs of root.
  • name_classes – name of all the sub-dirs/classes inside the root.
  • total_files – total number of files in all the sub-dir/classes.
  • get_basename(full_path, include_extension=True) source

    returns the basename of the file or the dir name at end of given path. In case of file you can choose wether to include the extension or not.

    Parameters:
    • full_path – absolute/relative path to root directory containing all files.
    • include_extension – if the input full_path leads to file the by default the the file's extension in included in output string.
    Returns:

  • name of the file with/without extension or the base dir.
  • get_random_files(main_dir, count=1) source

    returns a list of randomly selected files from the root dir.

    Parameters:
    • main_dir – absolute/relative path to root directory containing all files.
    • count – the number of files to get from root and its sub-dir.
    Returns:

  • list containing full paths to randomly selected files.
  • del_all_files(main_dir, confirmation=True) source

    delete all files from root and all its sub-dirs.

    Parameters:
    • main_dir – absolute/relative path to root directory containing all files.
    • confirmation – confirm before deleting the files.
    Returns:

  • None.
  • Usage

    For further details and more examples visit my github

    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

    fmutils-0.1.1.tar.gz (5.1 kB view details)

    Uploaded Source

    File details

    Details for the file fmutils-0.1.1.tar.gz.

    File metadata

    • Download URL: fmutils-0.1.1.tar.gz
    • Upload date:
    • Size: 5.1 kB
    • Tags: Source
    • Uploaded using Trusted Publishing? No
    • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

    File hashes

    Hashes for fmutils-0.1.1.tar.gz
    Algorithm Hash digest
    SHA256 65ddf9354c0648b7520b751824f0bd3cbe373b5033c46f1ff18745f7790b973d
    MD5 55539aa0f68d66dd1f1726ebe9a60992
    BLAKE2b-256 48a359caafcba89c1b6f9c75e873f216220ee4c899f063d15bb7bdb3cd59bd9f

    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