Skip to content

Instantly share code, notes, and snippets.

@Infernio
Created April 7, 2023 14:09
Show Gist options
  • Save Infernio/bcc57213f13a543318387be88579bfd1 to your computer and use it in GitHub Desktop.
Save Infernio/bcc57213f13a543318387be88579bfd1 to your computer and use it in GitHub Desktop.
Small script to find duplicate files in the core/override folder for Dragon Age: Origins & Dragon Age II
#!/bin/python
# find_duplicates.py
# License: MIT
#
# Small script to find duplicate files in the core/override folder for Dragon Age: Origins & Dragon Age II.
# Note that this does *not* scan .erf files, only loose files.
#
# To use it, run it with the path to your core/override folder.
import os
import sys
from collections import defaultdict
from pathlib import Path
def main():
if len(sys.argv) < 2:
print('Usage: find_duplicates.py <override folder>', file=sys.stderr)
sys.exit(1)
core_ov = Path(sys.argv[1]).resolve(strict=True)
all_files = defaultdict(list)
for f in core_ov.glob('**/*'):
if f.is_file():
all_files[f.name].append(os.fspath(f.relative_to(core_ov)))
duplicates = {f: d for f, d in all_files.items() if len(d) > 1}
if not duplicates:
print('No duplicate files found in override folder.')
print('Note that .erf files are not scanned.')
else:
print('Some duplicate files have been found:')
for f, d in duplicates.items():
print(f' * {f}, from the following sources:')
for fd in d:
print(f' - {fd}')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment