36 lines
896 B
Python
36 lines
896 B
Python
#!/usr/bin/env python3
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
missing = []
|
|
present = []
|
|
|
|
for line in sys.stdin:
|
|
line = line.rstrip('\n')
|
|
if not line:
|
|
continue
|
|
try:
|
|
item_id, path = line.split(' ', 1)
|
|
except ValueError:
|
|
print(f"BAD LINE: {line!r}", file=sys.stderr)
|
|
continue
|
|
|
|
if Path(path).exists():
|
|
present.append((item_id, path))
|
|
else:
|
|
missing.append((item_id, path))
|
|
|
|
with open('/music/beets/audit.stale-inbox-missing.tsv', 'w') as f:
|
|
for item_id, path in missing:
|
|
f.write(f'{item_id}\t{path}\n')
|
|
|
|
with open('/music/beets/audit.stale-inbox-present.tsv', 'w') as f:
|
|
for item_id, path in present:
|
|
f.write(f'{item_id}\t{path}\n')
|
|
|
|
print(f"missing: {len(missing)}")
|
|
print(f"present: {len(present)}")
|
|
print("/music/beets/audit.stale-inbox-missing.tsv")
|
|
print("/music/beets/audit.stale-inbox-present.tsv")
|