name: pdf-rename description: Rename academic PDF papers to a standardized format "[Year] [Venue] Title.pdf" using a three-stage pipeline (Extract → Verify → Rename). Use when the user asks to organize, batch-rename, or metadata-enrich PDF files in a folder. Activates on keywords like "rename PDFs", "organize papers", "batch rename PDFs", "rename papers by metadata", "pdf重命名", "文献整理".
Rename academic PDFs to: [Year] [Venue] Title.pdf
Three-stage pipeline:
Extract → Verify → Rename
Anti-error principle: Never re-parse PDF content during Rename. The Manifest is the single source of truth.
# Stage 1: Extract raw text → manifest.json
python scripts/extract.py "<folder_path>"
# Stage 2: LLM parses raw_text → inject verified data → manifest_verified.json
# (Agent reads manifest.json raw_text field and writes to scripts/VERIFIED_DATA_*.py)
python scripts/apply_verified.py "<folder_path>"
# Stage 3: Preview / Execute
python scripts/execute.py "<folder_path>" --preview
python scripts/execute.py "<folder_path>" --execute
What it does:
- Reads first 3 pages of each PDF
- Stores raw text in manifest.json → raw_text field
- Extracts year_hint from filename prefix
- Detects potential duplicates by filename similarity
Manifest schema — see references/manifest_spec.md
The agent reads manifest.json, parses each raw_text field, and writes verified metadata.
Steps:
1. Read manifest.json
2. For each entry, parse the raw_text to extract: title, authors, venue, year, abstract
3. Create or update scripts/VERIFIED_DATA_*.py with verified entries
VERIFIED_DATA format:
VERIFIED_DATA = {
"OriginalFilename.pdf": {
"title": "Correct Paper Title",
"year": "2024",
"venue": "NeurIPS",
"confirmed": True # must be True to be renamed
},
}
Rules:
- Key must exactly match the original filename
- confirmed: True → status becomes ready → will be renamed
- confirmed: False or omitted → skipped
- Multiple VERIFIED_DATA_*.py files are auto-merged
- Prefer venue/conference year over filename year (e.g., arXiv 2022 → NeurIPS 2024)
⚠️ Key gotchas during parsing:
- Multi-line titles: pypdf concatenates lines without spaces (e.g., "Direct score maximization outperformsplanning loss") — use context to infer correct split
- Journal refs at top of page: "Math. Program. (2012) 133..." is NOT the title — read further
- arXiv papers: use conference year if published, otherwise use arXiv year
- Non-paper files (book chapters, lecture notes, loss curves): set confirmed: False and skip
Then run:
python scripts/apply_verified.py "<folder_path>"
status == 'ready' files are renamed(1), (2) suffixes<folder>/_backup_YYYYMMDD_HHMMSS/python scripts/execute.py "<folder_path>" --preview # dry run
python scripts/execute.py "<folder_path>" --execute # rename
| Script | Purpose |
|---|---|
scripts/extract.py |
Stage 1: extract raw PDF text → manifest.json |
scripts/apply_verified.py |
Stage 2: inject verified metadata → manifest_verified.json |
scripts/execute.py |
Stage 3: rename files (preview or execute) |
scripts/llm_parse.py |
(Optional) programmatic LLM parsing via gateway API |
7w4.net小葱技能站,你的AI助手技能库。
| Symptom | Cause | Fix |
|---|---|---|
raw_text empty |
PDF is a scan | Skip (confirmed: False) or manually determine metadata |
| Title extracted without spaces | pypdf concatenates lines | LLM infers from context; use filename as hint |
| Wrong year (arXiv ≠ conference) | Used filename year | Use venue year from raw_text, not filename |
| DOI/journal ref at top of page | Metadata precedes title | Read past it — title is usually after |
| Middle-dot author lines misidentified | · separator in names |
LLM handles via semantic understanding |
| Non-paper files renamed | No filter applied | Set confirmed: False for non-papers |
| Windows filename encoding garbled | Chinese/non-ASCII chars in PowerShell | Use Python scripts, not manual file ops |
| Ligature artifacts | PDF encoding (e.g., fi → fi) |
clean_title_text() in extract.py handles these |
references/manifest_spec.md — Full manifest JSON schemareferences/venue_abbrev.md — Standard venue abbreviation map这个工具质量不错,能够有效整理学术论文 PDF,按年份、期刊/会议、标题重新命名。防错机制很用心,预览重命名、备份恢复、确认后才执行,三重保护让人安心。文档写得很详细,新手也能快速上手。不过工具包里有残留的测试数据比较碍眼,而且跨平台使用(比如 Linux/Mac)可能会有路径问题。整体适合有大量论文需要整理的用户,但中文文件名支持一般。.