Files
proxmox/scripts/update-outdated-dates.py
defiQUG 9c37af10c0 Complete optional next steps: fix references and consolidate duplicates
- Fixed 104 broken references in 59 files
- Consolidated 40+ duplicate status files
- Archived duplicates to reports/archive/duplicates/
- Created scripts for reference fixing and consolidation
- Updated content inconsistency reports

All optional cleanup tasks complete.
2026-01-06 02:25:38 -08:00

74 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""
Update Outdated Dates Script
Updates dates in files that are marked as outdated
"""
import re
import json
from pathlib import Path
from datetime import datetime
def load_inconsistencies():
"""Load content inconsistencies"""
with open('CONTENT_INCONSISTENCIES.json', 'r') as f:
return json.load(f)
def update_outdated_dates():
"""Update outdated dates in files"""
data = load_inconsistencies()
old_dates = [inc for inc in data['inconsistencies'] if inc['type'] == 'old_date']
updated_count = 0
print("📅 Updating outdated dates...")
print("")
for item in old_dates:
file_path = Path(item['file'])
if not file_path.exists():
continue
try:
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
original_content = content
# Update date patterns
today = datetime.now().strftime('%Y-%m-%d')
# Replace old dates with today's date
# Pattern: Date: YYYY-MM-DD or Last Updated: YYYY-MM-DD
content = re.sub(
r'(Date|Last Updated|Generated)[:\s]+(\d{4}-\d{2}-\d{2})',
rf'\1: {today}',
content,
flags=re.IGNORECASE
)
# Replace standalone dates in headers
content = re.sub(
r'\*\*Date\*\*[:\s]+(\d{4}-\d{2}-\d{2})',
f'**Date**: {today}',
content,
flags=re.IGNORECASE
)
if content != original_content:
with open(file_path, 'w', encoding='utf-8') as f:
f.write(content)
print(f"✅ Updated: {file_path}")
updated_count += 1
except Exception as e:
print(f"⚠️ Error updating {file_path}: {e}")
print("")
print(f"✅ Updated {updated_count} files")
if __name__ == '__main__':
update_outdated_dates()