Skip to main content

LongPathShutil

LongPathShutil is a drop-in Python wrapper for the methods of the built-in shutil library, providing enhanced support for long file paths on Windows. It leverages the \\?\ prefix to bypass the 260-character path length limit on Windows systems, and to be able to handle deeply nested or long file names. More info on the long path limitations on windows here

To keep compatibility, for Linux and Mac, it behaves as regular shutil.

Features

  • Seamlessly integrates long path support on Windows.
  • Fully compatible with the existing shutil functions. The functions only.
  • Automatically prefixes paths with \\?\ when necessary.
  • Offers functions to enable or disable long path support via the Windows registry at least for the applications supporting it. (Needs to be executed as admin)

Installation

You can install it like so:

pip install LongPathShutil

Usage

Enabling Long Paths in the Windows Registry

You can try programmatically enabling long paths via the registry. This does however require admin access and does not always work. Otherwise you can use the module as drop-in replacement for shutil on windows.

import LongPathShutil

# Enable long paths in the Windows registry (requires administrative privileges)
LongPathShutil.enable_long_paths_on_registry()

Basic File Operations

import LongPathShutil as shutil

# Copy a file with long paths
shutil.copy(r"C:\very\long\source\path\file.txt", r"C:\another\very\long\destination\path\file.txt")

# Move a directory with long paths
shutil.move(r"C:\very\long\source\directory", r"C:\another\very\long\destination\directory")

# Remove a directory tree with long paths
shutil.rmtree(r"C:\very\long\path\to\directory")

Full API

The LongPathShutil class provides all the functions available in shutil with the addition of long path support:

  • copyfile(), copy(), copy2()
  • move(), rmtree(), copytree()
  • make_archive(), unpack_archive(), get_archive_formats(), and more.

See the complete list of functions here.

Why Use LongPathShutil?

By default, Windows imposes a 260-character limit on paths, which can cause problems when dealing with deeply nested directory structures or long filenames. This module automatically adds the necessary prefix to bypass this limitation, allowing for seamless file operations across various platforms.

Contributing

If you find a bug or have a suggestion, feel free to open an issue or submit a pull request. Make sure to check the CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for LongPathShutil 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for LongPathShutil 0.6
File Size Uploaded
longpathshutil-0.6.tar.gz 4.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for LongPathShutil 0.6
File Interpreter ABI Platform
longpathshutil-0.6-py3-none-any.whl Python 3 none any Details

Total release size: 9.1 kB

Release files / longpathshutil-0.6.tar.gz

Download URL longpathshutil-0.6.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bff6a3b56698223a77d9ded5147805dbc5b27ad677d0276ac20bf6abe65565f9
BLAKE2b-256 checksum
How to use checksums
76a5696def2f47a1e582af7f175ffea5317d6eae4edb0082c9b57bc94c9d4e7c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release files / longpathshutil-0.6-py3-none-any.whl

Download URL longpathshutil-0.6-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6dd5602fe8688c6bb95b26246f618aa10908b81134ed1848ef078dc8b594b010
BLAKE2b-256 checksum
How to use checksums
afd90aac53b87aeb856d3e9e1c0430e243559ed3073d02290737a10f37f7a962
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6 This release

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page