{"id":16959687,"url":"https://github.com/fabiocaccamo/python-fsutil","last_synced_at":"2025-05-15T07:03:39.119Z","repository":{"id":41304077,"uuid":"307334017","full_name":"fabiocaccamo/python-fsutil","owner":"fabiocaccamo","description":":computer: :wrench: high-level file-system operations for lazy devs.","archived":false,"fork":false,"pushed_at":"2025-05-12T16:56:46.000Z","size":300,"stargazers_count":215,"open_issues_count":10,"forks_count":14,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-15T07:02:37.273Z","etag":null,"topics":["create","directories","directory","download","file","files","filesystem","glob","list","os","path","python","read","remove","rename","search","shutil","utilities","utility","write"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fabiocaccamo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["fabiocaccamo"],"polar":"fabiocaccamo","ko_fi":"fabiocaccamo","liberapay":"fabiocaccamo","tidelift":"pypi/python-fsutil","custom":["https://www.buymeacoffee.com/fabiocaccamo","https://www.paypal.me/fabiocaccamo"]}},"created_at":"2020-10-26T10:20:43.000Z","updated_at":"2025-05-11T23:03:22.000Z","dependencies_parsed_at":"2023-02-17T09:46:36.621Z","dependency_job_id":"796a5762-3225-4150-a488-1d829a4197dc","html_url":"https://github.com/fabiocaccamo/python-fsutil","commit_stats":{"total_commits":396,"total_committers":4,"mean_commits":99.0,"dds":"0.20707070707070707","last_synced_commit":"49206676a1ceb377e329c3303f7d8758f208b5f9"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fpython-fsutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fpython-fsutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fpython-fsutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiocaccamo%2Fpython-fsutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiocaccamo","download_url":"https://codeload.github.com/fabiocaccamo/python-fsutil/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254291961,"owners_count":22046424,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["create","directories","directory","download","file","files","filesystem","glob","list","os","path","python","read","remove","rename","search","shutil","utilities","utility","write"],"created_at":"2024-10-13T22:45:46.680Z","updated_at":"2025-05-15T07:03:39.066Z","avatar_url":"https://github.com/fabiocaccamo.png","language":"Python","readme":"[![](https://img.shields.io/pypi/pyversions/python-fsutil.svg?color=blue\u0026logo=python\u0026logoColor=white)](https://www.python.org/)\n[![](https://img.shields.io/pypi/v/python-fsutil.svg?color=blue\u0026logo=pypi\u0026logoColor=white)](https://pypi.org/project/python-fsutil/)\n[![](https://static.pepy.tech/badge/python-fsutil/month)](https://pepy.tech/project/python-fsutil)\n[![](https://img.shields.io/github/stars/fabiocaccamo/python-fsutil?logo=github\u0026style=flat)](https://github.com/fabiocaccamo/python-fsutil/stargazers)\n[![](https://img.shields.io/pypi/l/python-fsutil.svg?color=blue)](https://github.com/fabiocaccamo/python-fsutil/blob/main/LICENSE.txt)\n\n[![](https://results.pre-commit.ci/badge/github/fabiocaccamo/python-fsutil/main.svg)](https://results.pre-commit.ci/latest/github/fabiocaccamo/python-fsutil/main)\n[![](https://img.shields.io/github/actions/workflow/status/fabiocaccamo/python-fsutil/test-package.yml?branch=main\u0026label=build\u0026logo=github)](https://github.com/fabiocaccamo/python-fsutil)\n[![](https://img.shields.io/codecov/c/gh/fabiocaccamo/python-fsutil?logo=codecov)](https://codecov.io/gh/fabiocaccamo/python-fsutil)\n[![](https://img.shields.io/codacy/grade/fc40788ae7d74d1fb34a38934113c4e5?logo=codacy)](https://www.codacy.com/app/fabiocaccamo/python-fsutil)\n[![](https://img.shields.io/codeclimate/maintainability/fabiocaccamo/python-fsutil?logo=code-climate)](https://codeclimate.com/github/fabiocaccamo/python-fsutil/)\n[![](https://img.shields.io/badge/code%20style-black-000000.svg?logo=python\u0026logoColor=black)](https://github.com/psf/black)\n[![](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n\n# python-fsutil\nhigh-level file-system operations for lazy devs.\n\n## Installation\n\n```bash\npip install python-fsutil\n```\n\n## Usage\n\nJust import the main module and call its methods.\n\n```python\nimport fsutil\n```\n\n### Methods\n\n-   [`assert_dir`](#assert_dir)\n-   [`assert_exists`](#assert_exists)\n-   [`assert_file`](#assert_file)\n-   [`assert_not_dir`](#assert_not_dir)\n-   [`assert_not_exists`](#assert_not_exists)\n-   [`assert_not_file`](#assert_not_file)\n-   [`clean_dir`](#clean_dir)\n-   [`convert_size_bytes_to_string`](#convert_size_bytes_to_string)\n-   [`convert_size_string_to_bytes`](#convert_size_string_to_bytes)\n-   [`copy_dir`](#copy_dir)\n-   [`copy_dir_content`](#copy_dir_content)\n-   [`copy_file`](#copy_file)\n-   [`create_dir`](#create_dir)\n-   [`create_file`](#create_file)\n-   [`create_tar_file`](#create_tar_file)\n-   [`create_zip_file`](#create_zip_file)\n-   [`delete_dir`](#delete_dir)\n-   [`delete_dir_content`](#delete_dir_content)\n-   [`delete_dirs`](#delete_dirs)\n-   [`delete_file`](#delete_file)\n-   [`delete_files`](#delete_files)\n-   [`download_file`](#download_file) *(require `requests` to be installed)*\n-   [`exists`](#exists)\n-   [`extract_tar_file`](#extract_tar_file)\n-   [`extract_zip_file`](#extract_zip_file)\n-   [`get_dir_creation_date`](#get_dir_creation_date)\n-   [`get_dir_creation_date_formatted`](#get_dir_creation_date_formatted)\n-   [`get_dir_hash`](#get_dir_hash)\n-   [`get_dir_last_modified_date`](#get_dir_last_modified_date)\n-   [`get_dir_last_modified_date_formatted`](#get_dir_last_modified_date_formatted)\n-   [`get_dir_size`](#get_dir_size)\n-   [`get_dir_size_formatted`](#get_dir_size_formatted)\n-   [`get_file_basename`](#get_file_basename)\n-   [`get_file_creation_date`](#get_file_creation_date)\n-   [`get_file_creation_date_formatted`](#get_file_creation_date_formatted)\n-   [`get_file_extension`](#get_file_extension)\n-   [`get_file_hash`](#get_file_hash)\n-   [`get_file_last_modified_date`](#get_file_last_modified_date)\n-   [`get_file_last_modified_date_formatted`](#get_file_last_modified_date_formatted)\n-   [`get_file_size`](#get_file_size)\n-   [`get_file_size_formatted`](#get_file_size_formatted)\n-   [`get_filename`](#get_filename)\n-   [`get_parent_dir`](#get_parent_dir)\n-   [`get_permissions`](#get_permissions)\n-   [`get_unique_name`](#get_unique_name)\n-   [`is_dir`](#is_dir)\n-   [`is_empty`](#is_empty)\n-   [`is_empty_dir`](#is_empty_dir)\n-   [`is_empty_file`](#is_empty_file)\n-   [`is_file`](#is_file)\n-   [`join_filename`](#join_filename)\n-   [`join_filepath`](#join_filepath)\n-   [`join_path`](#join_path)\n-   [`list_dirs`](#list_dirs)\n-   [`list_files`](#list_files)\n-   [`make_dirs`](#make_dirs)\n-   [`make_dirs_for_file`](#make_dirs_for_file)\n-   [`move_dir`](#move_dir)\n-   [`move_file`](#move_file)\n-   [`read_file`](#read_file)\n-   [`read_file_from_url`](#read_file_from_url) *(requires `requests` to be installed)*\n-   [`read_file_json`](#read_file_json)\n-   [`read_file_lines`](#read_file_lines)\n-   [`read_file_lines_count`](#read_file_lines_count)\n-   [`remove_dir`](#remove_dir)\n-   [`remove_dir_content`](#remove_dir_content)\n-   [`remove_dirs`](#remove_dirs)\n-   [`remove_file`](#remove_file)\n-   [`remove_files`](#remove_files)\n-   [`rename_dir`](#rename_dir)\n-   [`rename_file`](#rename_file)\n-   [`rename_file_basename`](#rename_file_basename)\n-   [`rename_file_extension`](#rename_file_extension)\n-   [`replace_dir`](#replace_dir)\n-   [`replace_file`](#replace_file)\n-   [`search_dirs`](#search_dirs)\n-   [`search_files`](#search_files)\n-   [`set_permissions`](#set_permissions)\n-   [`split_filename`](#split_filename)\n-   [`split_filepath`](#split_filepath)\n-   [`split_path`](#split_path)\n-   [`transform_filepath`](#transform_filepath)\n-   [`write_file`](#write_file)\n-   [`write_file_json`](#write_file_json)\n\n\n#### `assert_dir`\n\n```python\n# Raise an OSError if the given path doesn't exist or it is not a directory.\nfsutil.assert_dir(path)\n```\n\n#### `assert_exists`\n\n```python\n# Raise an OSError if the given path doesn't exist.\nfsutil.assert_exists(path)\n```\n\n#### `assert_file`\n\n```python\n# Raise an OSError if the given path doesn't exist or it is not a file.\nfsutil.assert_file(path)\n```\n\n#### `assert_not_dir`\n\n```python\n# Raise an OSError if the given path is an existing directory.\nfsutil.assert_not_dir(path)\n```\n\n#### `assert_not_exists`\n\n```python\n# Raise an OSError if the given path already exists.\nfsutil.assert_not_exists(path)\n```\n\n#### `assert_not_file`\n\n```python\n# Raise an OSError if the given path is an existing file.\nfsutil.assert_not_file(path)\n```\n\n#### `clean_dir`\n\n```python\n# Clean a directory by removing empty sub-directories and/or empty files.\nfsutil.clean_dir(path, dirs=True, files=True)\n```\n\n#### `convert_size_bytes_to_string`\n\n```python\n# Convert the given size bytes to string using the right unit suffix.\nsize_str = fsutil.convert_size_bytes_to_string(size)\n```\n\n#### `convert_size_string_to_bytes`\n\n```python\n# Convert the given size string to bytes.\nsize_bytes = fsutil.convert_size_string_to_bytes(size)\n```\n\n#### `copy_dir`\n\n```python\n# Copy the directory at the given path and all its content to dest path.\n# If overwrite is not allowed and dest path exists, an OSError is raised.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.copytree\nfsutil.copy_dir(path, dest, overwrite=False, **kwargs)\n```\n\n#### `copy_dir_content`\n\n```python\n# Copy the content of the directory at the given path to dest path.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.copytree\nfsutil.copy_dir_content(path, dest, **kwargs)\n```\n\n#### `copy_file`\n\n```python\n# Copy the file at the given path and its metadata to dest path.\n# If overwrite is not allowed and dest path exists, an OSError is raised.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.copy2\nfsutil.copy_file(path, dest, overwrite=False, **kwargs)\n```\n\n#### `create_dir`\n\n```python\n# Create directory at the given path.\n# If overwrite is not allowed and path exists, an OSError is raised.\nfsutil.create_dir(path, overwrite=False)\n```\n\n#### `create_file`\n\n```python\n# Create file with the specified content at the given path.\n# If overwrite is not allowed and path exists, an OSError is raised.\nfsutil.create_file(path, content=\"\", overwrite=False)\n```\n\n#### `create_tar_file`\n\n```python\n# Create tar file at path compressing directories/files listed in content_paths.\n# If overwrite is allowed and dest tar already exists, it will be overwritten.\nfsutil.create_tar_file(path, content_paths, overwrite=True, compression=\"gzip\")\n```\n\n#### `create_zip_file`\n\n```python\n# Create zip file at path compressing directories/files listed in content_paths.\n# If overwrite is allowed and dest zip already exists, it will be overwritten.\nfsutil.create_zip_file(path, content_paths, overwrite=True, compression=zipfile.ZIP_DEFLATED)\n```\n\n#### `delete_dir`\n\n```python\n# Alias for remove_dir.\nfsutil.delete_dir(path)\n```\n\n#### `delete_dir_content`\n\n```python\n# Alias for remove_dir_content.\nfsutil.delete_dir_content(path)\n```\n\n#### `delete_dirs`\n\n```python\n# Alias for remove_dirs.\nfsutil.delete_dirs(*paths)\n```\n\n#### `delete_file`\n\n```python\n# Alias for remove_file.\nfsutil.delete_file(path)\n```\n\n#### `delete_files`\n\n```python\n# Alias for remove_files.\nfsutil.delete_files(*paths)\n```\n\n#### `download_file`\n\n```python\n# Download a file from url to the given dirpath and return the filepath.\n# If dirpath is not provided, the file will be downloaded to a temp directory.\n# If filename is provided, the file will be named using filename.\n# It is possible to pass extra request options (eg. for authentication) using **kwargs.\nfilepath = fsutil.download_file(url, dirpath=None, filename=\"archive.zip\", chunk_size=8192, **kwargs)\n```\n\n#### `exists`\n\n```python\n# Check if a directory of a file exists at the given path.\nvalue = fsutil.exists(path)\n```\n\n#### `extract_tar_file`\n\n```python\n# Extract tar file at path to dest path.\n# If autodelete, the archive will be deleted after extraction.\n# If content_paths list is defined, only listed items will be extracted, otherwise all.\nfsutil.extract_tar_file(path, dest, content_paths=None, autodelete=False)\n```\n\n#### `extract_zip_file`\n\n```python\n# Extract zip file at path to dest path.\n# If autodelete, the archive will be deleted after extraction.\n# If content_paths list is defined, only listed items will be extracted, otherwise all.\nfsutil.extract_zip_file(path, dest, content_paths=None, autodelete=False)\n```\n\n#### `get_dir_creation_date`\n\n```python\n# Get the directory creation date.\ndate = fsutil.get_dir_creation_date(path)\n```\n\n#### `get_dir_creation_date_formatted`\n\n```python\n# Get the directory creation date formatted using the given format.\ndate_str = fsutil.get_dir_creation_date_formatted(path, format='%Y-%m-%d %H:%M:%S')\n```\n\n#### `get_dir_hash`\n\n```python\n# Get the hash of the directory at the given path using\n# the specified algorithm function (md5 by default).\nhash = fsutil.get_dir_hash(path, func=\"md5\")\n```\n\n#### `get_dir_last_modified_date`\n\n```python\n# Get the directory last modification date.\ndate = fsutil.get_dir_last_modified_date(path)\n```\n\n#### `get_dir_last_modified_date_formatted`\n\n```python\n# Get the directory last modification date formatted using the given format.\ndate_str = fsutil.get_dir_last_modified_date_formatted(path, format=\"%Y-%m-%d %H:%M:%S\")\n```\n\n#### `get_dir_size`\n\n```python\n# Get the directory size in bytes.\nsize = fsutil.get_dir_size(path)\n```\n\n#### `get_dir_size_formatted`\n\n```python\n# Get the directory size formatted using the right unit suffix.\nsize_str = fsutil.get_dir_size_formatted(path)\n```\n\n#### `get_file_basename`\n\n```python\n# Get the file basename from the given path/url.\nbasename = fsutil.get_file_basename(path)\n```\n\n#### `get_file_creation_date`\n\n```python\n# Get the file creation date.\ndate = fsutil.get_file_creation_date(path)\n```\n\n#### `get_file_creation_date_formatted`\n\n```python\n# Get the file creation date formatted using the given format.\ndate_str = fsutil.get_file_creation_date_formatted(path, format=\"%Y-%m-%d %H:%M:%S\")\n```\n\n#### `get_file_extension`\n\n```python\n# Get the file extension from the given path/url.\nextension = fsutil.get_file_extension(path)\n```\n\n#### `get_file_hash`\n\n```python\n# Get the hash of the file at the given path using\n# the specified algorithm function (md5 by default).\nfilehash = fsutil.get_file_hash(path, func=\"md5\")\n```\n\n#### `get_file_last_modified_date`\n\n```python\n# Get the file last modification date.\ndate = fsutil.get_file_last_modified_date(path)\n```\n\n#### `get_file_last_modified_date_formatted`\n\n```python\n# Get the file last modification date formatted using the given format.\ndate_str = fsutil.get_file_last_modified_date_formatted(path, format=\"%Y-%m-%d %H:%M:%S\")\n```\n\n#### `get_file_size`\n\n```python\n# Get the file size in bytes.\nsize = fsutil.get_file_size(path)\n```\n\n#### `get_file_size_formatted`\n\n```python\n# Get the file size formatted using the right unit suffix.\nsize_str = fsutil.get_file_size_formatted(path)\n```\n\n#### `get_filename`\n\n```python\n# Get the filename from the given path/url.\nfilename = fsutil.get_filename(path)\n```\n\n#### `get_parent_dir`\n\n```python\n# Get the parent directory for the given path going up N levels.\nparent_dir = fsutil.get_parent_dir(path, levels=1)\n```\n\n#### `get_permissions`\n\n```python\n# Get the file/directory permissions.\npermissions = fsutil.get_permissions(path)\n```\n\n#### `get_unique_name`\n\n```python\n# Get a unique name for a directory/file at the given directory path.\nunique_name = fsutil.get_unique_name(path, prefix=\"\", suffix=\"\", extension=\"\", separator=\"-\")\n```\n\n#### `is_dir`\n\n```python\n# Determine whether the specified path represents an existing directory.\nvalue = fsutil.is_dir(path)\n```\n\n#### `is_empty`\n\n```python\n# Determine whether the specified path represents an empty directory or an empty file.\nvalue = fsutil.is_empty(path)\n```\n\n#### `is_empty_dir`\n\n```python\n# Determine whether the specified path represents an empty directory.\nvalue = fsutil.is_empty_dir(path)\n```\n\n#### `is_empty_file`\n\n```python\n# Determine whether the specified path represents an empty file.\nvalue = fsutil.is_empty_file(path)\n```\n\n#### `is_file`\n\n```python\n# Determine whether the specified path represents an existing file.\nvalue = fsutil.is_file(path)\n```\n\n#### `join_filename`\n\n```python\n# Create a filename joining the file basename and the extension.\nfilename = fsutil.join_filename(basename, extension)\n```\n\n#### `join_filepath`\n\n```python\n# Create a filepath joining the directory path and the filename.\nfilepath = fsutil.join_filepath(dirpath, filename)\n```\n\n#### `join_path`\n\n```python\n# Create a path joining path and paths.\n# If path is __file__ (or a .py file), the resulting path will be relative\n# to the directory path of the module in which it's used.\npath = fsutil.join_path(path, *paths)\n```\n\n#### `list_dirs`\n\n```python\n# List all directories contained at the given directory path.\ndirs = fsutil.list_dirs(path)\n```\n\n#### `list_files`\n\n```python\n# List all files contained at the given directory path.\nfiles = fsutil.list_files(path)\n```\n\n#### `make_dirs`\n\n```python\n# Create the directories needed to ensure that the given path exists.\n# If a file already exists at the given path an OSError is raised.\nfsutil.make_dirs(path)\n```\n\n#### `make_dirs_for_file`\n\n```python\n# Create the directories needed to ensure that the given path exists.\n# If a directory already exists at the given path an OSError is raised.\nfsutil.make_dirs_for_file(path)\n```\n\n#### `move_dir`\n\n```python\n# Move an existing dir from path to dest directory.\n# If overwrite is not allowed and dest path exists, an OSError is raised.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.move\nfsutil.move_dir(path, dest, overwrite=False, **kwargs)\n```\n\n#### `move_file`\n\n```python\n# Move an existing file from path to dest directory.\n# If overwrite is not allowed and dest path exists, an OSError is raised.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.move\nfsutil.move_file(path, dest, overwrite=False, **kwargs)\n```\n\n#### `read_file`\n\n```python\n# Read the content of the file at the given path using the specified encoding.\ncontent = fsutil.read_file(path, encoding=\"utf-8\")\n```\n\n#### `read_file_from_url`\n\n```python\n# Read the content of the file at the given url.\ncontent = fsutil.read_file_from_url(url, **kwargs)\n```\n\n#### `read_file_json`\n\n```python\n# Read and decode a json encoded file at the given path.\ndata = fsutil.read_file_json(path, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None)\n```\n\n#### `read_file_lines`\n\n```python\n# Read file content lines.\n# It is possible to specify the line indexes (negative indexes too),\n# very useful especially when reading large files.\ncontent = fsutil.read_file_lines(path, line_start=0, line_end=-1, strip_white=True, skip_empty=True, encoding=\"utf-8\")\n```\n\n#### `read_file_lines_count`\n\n```python\n# Read file lines count.\nlines_count = fsutil.read_file_lines_count(path)\n```\n\n#### `remove_dir`\n\n```python\n# Remove a directory at the given path and all its content.\n# If the directory is removed with success returns True, otherwise False.\n# More informations about kwargs supported options here:\n# https://docs.python.org/3/library/shutil.html#shutil.rmtree\nfsutil.remove_dir(path, **kwargs)\n```\n\n#### `remove_dir_content`\n\n```python\n# Removes all directory content (both sub-directories and files).\nfsutil.remove_dir_content(path)\n```\n\n#### `remove_dirs`\n\n```python\n# Remove multiple directories at the given paths and all their content.\nfsutil.remove_dirs(*paths)\n```\n\n#### `remove_file`\n\n```python\n# Remove a file at the given path.\n# If the file is removed with success returns True, otherwise False.\nfsutil.remove_file(path)\n```\n\n#### `remove_files`\n\n```python\n# Remove multiple files at the given paths.\nfsutil.remove_files(*paths)\n```\n\n#### `rename_dir`\n\n```python\n# Rename a directory with the given name.\n# If a directory or a file with the given name already exists, an OSError is raised.\nfsutil.rename_dir(path, name)\n```\n\n#### `rename_file`\n\n```python\n# Rename a file with the given name.\n# If a directory or a file with the given name already exists, an OSError is raised.\nfsutil.rename_file(path, name)\n```\n\n#### `rename_file_basename`\n\n```python\n# Rename a file basename with the given basename.\nfsutil.rename_file_basename(path, basename)\n```\n\n#### `rename_file_extension`\n\n```python\n# Rename a file extension with the given extension.\nfsutil.rename_file_extension(path, extension)\n```\n\n#### `replace_dir`\n\n```python\n# Replace directory at the specified path with the directory located at src.\n# If autodelete, the src directory will be removed at the end of the operation.\n# Optimized for large directories.\nfsutil.replace_dir(path, src, autodelete=False)\n```\n\n#### `replace_file`\n\n```python\n# Replace file at the specified path with the file located at src.\n# If autodelete, the src file will be removed at the end of the operation.\n# Optimized for large files.\nfsutil.replace_file(path, src, autodelete=False)\n```\n\n#### `search_dirs`\n\n```python\n# Search for directories at path matching the given pattern.\ndirs = fsutil.search_dirs(path, pattern=\"**/*\")\n```\n\n#### `search_files`\n\n```python\n# Search for files at path matching the given pattern.\nfiles = fsutil.search_files(path, pattern=\"**/*.*\")\n```\n\n#### `set_permissions`\n\n```python\n# Set the file/directory permissions.\nfsutil.set_permissions(path, 700)\n```\n\n#### `split_filename`\n\n```python\n# Split a filename and returns its basename and extension.\nbasename, extension = fsutil.split_filename(path)\n```\n\n#### `split_filepath`\n\n```python\n# Split a filename and returns its directory-path and filename.\ndirpath, filename = fsutil.split_filepath(path)\n```\n\n#### `split_path`\n\n```python\n# Split a path and returns its path-names.\npath_names = fsutil.split_path(path)\n```\n\n#### `transform_filepath`\n\n```python\n# Trasform a filepath by applying the provided optional changes.\nfilepath = fsutil.transform_filepath(path, dirpath=None, basename=lambda b: slugify(b), extension=\"webp\")\n```\n\n#### `write_file`\n\n```python\n# Write file with the specified content at the given path.\nfsutil.write_file(path, content, append=False, encoding=\"utf-8\", atomic=False)\n```\n\n#### `write_file_json`\n\n```python\n# Write a json file at the given path with the specified data encoded in json format.\nfsutil.write_file_json(path, data, encoding=\"utf-8\", atomic=False, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False)\n```\n\n## Testing\n```bash\n# clone repository\ngit clone https://github.com/fabiocaccamo/python-fsutil.git \u0026\u0026 cd python-fsutil\n\n# create virtualenv and activate it\npython -m venv venv \u0026\u0026 . venv/bin/activate\n\n# upgrade pip\npython -m pip install --upgrade pip\n\n# install requirements\npython -m pip install -r requirements.txt -r requirements-test.txt\n\n# install pre-commit to run formatters and linters\npre-commit install --install-hooks\n\n# run tests using tox\ntox\n\n# or run tests using pytest\npytest\n```\n\n## License\nReleased under [MIT License](LICENSE.txt).\n\n---\n\n## Supporting\n\n- :star: Star this project on [GitHub](https://github.com/fabiocaccamo/python-fsutil)\n- :octocat: Follow me on [GitHub](https://github.com/fabiocaccamo)\n- :blue_heart: Follow me on [Twitter](https://twitter.com/fabiocaccamo)\n- :moneybag: Sponsor me on [Github](https://github.com/sponsors/fabiocaccamo)\n\n## See also\n\n- [`python-benedict`](https://github.com/fabiocaccamo/python-benedict) - dict subclass with keylist/keypath support, I/O shortcuts (base64, csv, json, pickle, plist, query-string, toml, xml, yaml) and many utilities. 📘\n\n- [`python-fontbro`](https://github.com/fabiocaccamo/python-fontbro) - friendly font operations on top of fontTools. 🧢\n","funding_links":["https://github.com/sponsors/fabiocaccamo","https://polar.sh/fabiocaccamo","https://ko-fi.com/fabiocaccamo","https://liberapay.com/fabiocaccamo","https://tidelift.com/funding/github/pypi/python-fsutil","https://www.buymeacoffee.com/fabiocaccamo","https://www.paypal.me/fabiocaccamo"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiocaccamo%2Fpython-fsutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiocaccamo%2Fpython-fsutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiocaccamo%2Fpython-fsutil/lists"}