Skip to main content

Converts long Windows file paths to their short 8.3 format in a string where applicable.

Tested against Windows / Python 3.11 / Anaconda

pip install fullpath83replace

absolut_wpath_to_83(
    string, valid_string_ends=("<", ">", ":", '"', "|", "?", "*", "\n", "\r", " ")
):
    r"""

This function takes a string containing file paths and attempts to convert long
Windows file paths to their short 8.3 format where applicable. It identifies file
paths in the input string, checks if they exist, and if they do, replaces them
with their short 8.3 format versions.

Parameters:
- string (str): The input string containing file paths.
- valid_string_ends (tuple): A tuple of valid string endings 'c:\some long path' will not be converted if "'" is not in valid_string_ends

Returns:
- str: The input string with long file paths replaced by their short 8.3 format
  versions, while preserving valid string endings.

Example Usage:
	from fullpath83replace import absolut_wpath_to_83
	string1 = r'"C:\Users\hansc\Downloads\scrapingthreading.mp4" c:\babaexistsbutnottherest  "C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf" c:\baba c:\Windows'
	str1 = absolut_wpath_to_83(
		string1, valid_string_ends=("<", ">", ":", '"', "|", "?", "*", "\n", "\r", " ")
	)


	string2 = r'C:\Users\hansc\Downloads\scrapingthreading.mp4 c:\babaexists butnot therest  C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf c:\baba "c:\Windows" '
	str2 = absolut_wpath_to_83(
		string2, valid_string_ends=("<", ">", ":", '"', "|", "?", "*", "\n", "\r", " ")
	)

	string3 = r''' C:\Users\hansc\Downloads\scrapingthreading.mp4 c:\babaxxxas\asfasdxx\bi  'C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf' xxxxxxxxxxxxxxxxxx "c:\baba" c:\Windows'''
	str3 = absolut_wpath_to_83(
		string3, valid_string_ends=("<", ">", ":", '"', "|", "?", "*", "\n", "\r", " ", "'")
	)


	print(str1)
	print(string1)
	# "C:\Users\hansc\DOWNLO~1\SCRAPI~1.MP4" c:\babaexistsbutnottherest  "C:\Users\hansc\DOWNLO~1\ROGERL~1.PDF" c:\baba c:\Windows
	# "C:\Users\hansc\Downloads\scrapingthreading.mp4" c:\babaexistsbutnottherest  "C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf" c:\baba c:\Windows
	print(str2)
	print(string2)
	# C:\Users\hansc\DOWNLO~1\SCRAPI~1.MP4 c:\babaexists butnot therest  C:\Users\hansc\DOWNLO~1\ROGERL~1.PDF c:\baba "c:\Windows
	# C:\Users\hansc\Downloads\scrapingthreading.mp4 c:\babaexists butnot therest  C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf c:\baba "c:\Windows"
	print(str3)
	print(string3)
	#  C:\Users\hansc\DOWNLO~1\SCRAPI~1.MP4 c:\babaxxxas\asfasdxx\bi  'C:\Users\hansc\DOWNLO~1\ROGERL~1.PDF' xxxxxxxxxxxxxxxxxx "c:\baba" c:\Windows
	#  C:\Users\hansc\Downloads\scrapingthreading.mp4 c:\babaxxxas\asfasdxx\bi  'C:\Users\hansc\Downloads\Roger LeRoy Miller, Daniel K. Benjamin, Douglass C. North - The Economics of Public Issues-Pearson College Div (2017).pdf' xxxxxxxxxxxxxxxxxx "c:\baba" c:\Windows

Metadata

Release files for fullpath83replace 0.12

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

Source distribution (sdist)

Source distribution for fullpath83replace 0.12
File Size Uploaded Provenance Actions
fullpath83replace-0.12.tar.gz 4.5 kB Without provenance Details for fullpath83replace-0.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fullpath83replace 0.12
File Interpreter ABI Platform Actions
fullpath83replace-0.12-py3-none-any.whl Python 3 none any Details for fullpath83replace-0.12-py3-none-any.whl

Total release size: 10.8 kB

Release files / fullpath83replace-0.12.tar.gz

Download URL fullpath83replace-0.12.tar.gz
Size 4.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a8358efa268140182ffebab359c3bedc5773c3ee0e8738dec61390e5931a1a4
BLAKE2b-256 checksum
How to use checksums
55702ca9185ae6e623b57a5f055812192623f20b017f25b2318c51cc9c54b373
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / fullpath83replace-0.12-py3-none-any.whl

Download URL fullpath83replace-0.12-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49ad6086e63c304a3df88703b3b07e5e3048865e6b12c4f43dabd95e185de9f8
BLAKE2b-256 checksum
How to use checksums
a10473dc6c5a641f0f4c7afa1837962af130368075fed82ad4c3fc863801c7e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Security for fullpath83replace 0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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