Created
July 20, 2021 11:19
-
-
Save lukasgabriel/c09b0acbfa2f6c59b79c4c177dbfd3c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sortfilenames.py | |
# Run this command first to get the LongName.txt: dir Y:\ /s /b | sort /+143 /r > LongName.txt | |
from pathlib import WindowsPath | |
paths = [] | |
# Make sure to (re-)save the text file as UTF-8 ! | |
with open("LongName.txt", "r", encoding="utf-8") as infile: | |
for line in infile: | |
paths.append(WindowsPath(line)) | |
with open("LongName_sorted.txt", "w") as outfile: | |
for path in paths: | |
for component in path.parts: | |
if len(component) > 143: | |
outfile.write(f"{component.__str__()}\n ---> {path.__str__()}\n\n") | |
# Prints the offending path or filename first, then its full location underneath. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Lukas,
Thank you for your help. All is good now.