44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
CONVERTER_SCRIPT = os.path.join(BASE_DIR, ".gemini", "convert_to_pdf.py")
|
|
|
|
def main():
|
|
print(f"Scanning for manuals in: {BASE_DIR}")
|
|
count = 0
|
|
errors = 0
|
|
|
|
for root, dirs, files in os.walk(BASE_DIR):
|
|
# Skip .gemini and .git
|
|
if '.gemini' in dirs: dirs.remove('.gemini')
|
|
if '.git' in dirs: dirs.remove('.git')
|
|
|
|
# Filter for 'documentacao' folders mostly, but user might have others.
|
|
# User said "all manuals available". Usually they are in 'documentacao ...'.
|
|
# Let's check all .md files but exclude READMEs and Artifacts.
|
|
|
|
for file in files:
|
|
if file.lower().endswith('.md'):
|
|
if file.upper().startswith('README'): continue
|
|
if 'task.md' in file or 'implementation_plan.md' in file or 'walkthrough.md' in file: continue
|
|
|
|
# Check if it looks like a manual folder structure (optional, but safer)
|
|
# Or just convert everything. Let's convert everything that looks like a manual.
|
|
|
|
full_path = os.path.join(root, file)
|
|
print(f"Converting: {file}...")
|
|
|
|
try:
|
|
subprocess.check_call([sys.executable, CONVERTER_SCRIPT, full_path])
|
|
count += 1
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Error converting {file}: {e}")
|
|
errors += 1
|
|
|
|
print(f"\nBatch Completed.\nTotal Converted: {count}\nErrors: {errors}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|