Created
December 3, 2020 03:22
-
-
Save jeremy-rifkin/b8c70797279b300730d4b5c10177bbb3 to your computer and use it in GitHub Desktop.
7zip has trouble compressing a directory on windows if it contains two filenames which differ only in capitalization... This script will find problematic file pairs and delete conflicts.
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
import os | |
import sys | |
def main(): | |
filedict = {} | |
for path, dirs, files in os.walk(sys.argv[1]): | |
for f in files: | |
full_path = os.path.join(path, f) | |
l = full_path.lower() | |
if l not in filedict: | |
filedict[l] = [full_path] | |
else: | |
print("duplicate:") | |
print("{}".format(full_path)) | |
print("{}".format(filedict[l][-1])) | |
filedict[l].append(full_path) | |
while True: | |
ans = input("Resolve filename collisions? [y/n] ") | |
if ans == "y": | |
print("resolving collisions...") | |
for key, entry in filedict.items(): | |
for f in entry[1:]: | |
os.remove(f) | |
print("done") | |
break | |
elif ans == "n": | |
print("exiting") | |
break | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment