Jump to content

Resume Renamer 260120: Difference between revisions

From Game in the Brain Wiki
No edit summary
No edit summary
Line 108: Line 108:
   
   
{| class="wikitable"
{| class="wikitable"
|+
|+ Caption text
!
!
!
!
|-
|-
|
! Header text
|
|
|
|-
|-
|
| Example
|
|
|
|-
|
|
|
|
|}
|}
# Save and exit: Press Ctrl+O, Enter, then Ctrl+X.
# Save and exit: Press Ctrl+O, Enter, then Ctrl+X.

Revision as of 08:03, 20 January 2026

📂 Automated Resume Renamer & Organizer

For Ubuntu 24.04 using Local AI (Ollama)

1. The Problem

As an HR officer or Professor, you know that students and applicants rarely follow file naming conventions. You likely have a folder that looks like this:

  • Resume.pdf
  • CV_Final_v2.docx
  • MyResume(1).pdf
  • john_doe.pdf

The Goal: Automatically rename these files based on their content to a standard format:

YYMMDD Name Degree/Background.pdf

Example: 250101 Juan Dela Cruz BS Information Technology.pdf

2. Requirements Checklist

Please ensure you have the following ready before starting.

  • [ ] Ubuntu 24.04 System (Updated).
  • [ ] Python 3.12+ (Pre-installed on Ubuntu 24.04).
  • [ ] Ollama installed locally (The AI engine).
  • [ ] A Small Language Model pulled (e.g., granite3.3:2b or llama3.2).
  • [ ] Python Libraries: pdfplumber (for PDFs), python-docx (for Word), requests (to talk to Ollama).
  • [ ] No Images: The files must have embedded text. This script excludes OCR (Optical Character Recognition) to keep it fast and lightweight. Scanned images will be skipped.

3. How the Script Works (The Logic)

This script acts as a "Project Manager" that hires two distinct specialists to process each file. It does not blindly ask the AI for everything, as small AIs make mistakes with math and dates.

  1. File Discovery:
  • The script looks for .pdf and .docx files in the folder where the script is located.
  1. Text Extraction:
  • It pulls raw text. If the text is less than 50 characters (likely an image scan), it skips the file to prevent errors.
  1. The Date Specialist (Python Regex):
  • Logic: It scans the text for explicit years (e.g., "2023", "2024").
  • Rule: It ignores the word "Present". Why? If a resume from 2022 says "2022 - Present", treating "Present" as "Today" (2026) would incorrectly date the old resume. We stick to the highest printed number.
  • Output: Sets the date to Jan 1st of the highest year found (e.g., 240101).
  1. The Content Specialist (Ollama AI):
  • Logic: It sends the text to the local AI with strict instructions.
  • Rule 1 (Priority): It looks for a Degree (e.g., "BS IT") first. It is forbidden from using "Intern" or "Student" if a degree is found.
  • Rule 2 (Fallback): If the AI fails to find a name, the script grabs the first line of the document as a fallback.
  1. Sanitization & Renaming:
  • It fixes "Spaced Names" (e.g., J O H N -> John).
  • It ensures the filename isn't too long.
It renames the file only if the name doesn't already exist.

4. Installation Guide (Ubuntu 24.04)

Open your terminal (Ctrl+Alt+T) and follow these steps exactly.

Step A: System Update

Ensure your system tools are fresh to avoid installation conflicts.

sudo apt update && sudo apt upgrade -y

Step B: Install Ollama & The Model

  1. Install the Ollama Engine:
curl -fsSL [https://ollama.com/install.sh](https://ollama.com/install.sh) | sh
  1. Download the Brain (The Model): We use granite3.3:2b because it is very fast and follows formatting rules well.
ollama pull granite3.3:2b
  1. (Note: You can swap this for llama3 if you have a powerful computer, but Granite is sufficient for this task).

Step C: Setup Python Environment

Ubuntu 24.04 requires Virtual Environments (venv) for Python scripts to prevent breaking system tools.

  1. Create a Project Folder:
mkdir ~/resume_renamer
cd ~/resume_renamer
  1. Create the Virtual Environment:
python3 -m venv venv
  1. Activate the Environment:
source venv/bin/activate
  1. (You should see (venv) at the start of your command line now).
  2. Install Required Libraries:
pip install requests pdfplumber python-docx

Step D: Create the Script

  1. Create the python file:
nano rename_resumes.py
  1. Paste the code found in the file block below.
Caption text
Header text
Example
  1. Save and exit: Press Ctrl+O, Enter, then Ctrl+X.

5. Running the Renamer

This script is portable. It works on the files sitting next to it.

  1. Copy the Script: Move the rename_resumes.py file into your folder full of PDFs (e.g., ~/Documents/Student_CVs).
  2. Open Terminal in that folder: cd ~/Documents/Student_CVs
  3. Activate your Python Environment (Point to where you created it): source ~/resume_renamer/venv/bin/activate
  4. Run the script: python3 rename_resumes.py