add output path print

This commit is contained in:
Ray 2025-09-02 20:22:17 +08:00
parent 12400d7635
commit 288a4376a1

View file

@ -69,11 +69,15 @@ if __name__ == "__main__":
# Save results # Save results
pdf_name = os.path.splitext(os.path.basename(args.pdf_path))[0] pdf_name = os.path.splitext(os.path.basename(args.pdf_path))[0]
os.makedirs('./results', exist_ok=True) output_dir = './results'
output_file = f'{output_dir}/{pdf_name}_structure.json'
os.makedirs(output_dir, exist_ok=True)
with open(f'./results/{pdf_name}_structure.json', 'w', encoding='utf-8') as f: with open(output_file, 'w', encoding='utf-8') as f:
json.dump(toc_with_page_number, f, indent=2) json.dump(toc_with_page_number, f, indent=2)
print(f'Tree structure saved to: {output_file}')
elif args.md_path: elif args.md_path:
# Validate Markdown file # Validate Markdown file
if not args.md_path.lower().endswith(('.md', '.markdown')): if not args.md_path.lower().endswith(('.md', '.markdown')):
@ -119,7 +123,11 @@ if __name__ == "__main__":
# Save results # Save results
md_name = os.path.splitext(os.path.basename(args.md_path))[0] md_name = os.path.splitext(os.path.basename(args.md_path))[0]
os.makedirs('./results', exist_ok=True) output_dir = './results'
output_file = f'{output_dir}/{md_name}_structure.json'
os.makedirs(output_dir, exist_ok=True)
with open(f'./results/{md_name}_structure.json', 'w', encoding='utf-8') as f: with open(output_file, 'w', encoding='utf-8') as f:
json.dump(toc_with_page_number, f, indent=2, ensure_ascii=False) json.dump(toc_with_page_number, f, indent=2, ensure_ascii=False)
print(f'Tree structure saved to: {output_file}')