Your First Automation
Build a tool that renames messy files into organized, consistent names. Your first taste of directing AI to build for you.
Every lawyer has a folder like this:
scan001.pdf
Document (3).pdf
IMG_4521.pdf
contract_final_FINAL_v2.docx
Untitled.pdf
You know what these files are. Your computer doesn’t. Let’s build a tool that fixes this—and in doing so, learn the fundamental pattern of building with AI.
The Goal
We’ll build an automation that:
- Looks at files in a folder
- Asks you what each file is (client name, document type, date)
- Renames them consistently:
2024-03-15_Smith-v-Jones_Complaint.pdf
By the end, you’ll have a reusable tool for organizing any folder of documents.
Setting Up the Test
First, let’s create some messy files to work with. Start Claude in your workspace:
cd ~/Desktop/my-first-tool
claude
Now ask Claude to create test files:
Create 5 sample PDF files with messy names like "scan001.pdf",
"Document (3).pdf", "IMG_4521.pdf", etc. Just empty files for testing.
Claude will create these files. Verify by asking:
Show me what files are in this folder
You should see your messy test files.
Building the Renamer
Now for the main event. Give Claude this instruction:
Build me a file renaming tool. Here's what I need:
1. Look at all PDF files in the current folder
2. For each file, show me the current name and ask me for:
- Client or case name (e.g., "Smith v Jones")
- Document type (e.g., "Complaint", "Motion", "Contract")
- Date (e.g., "2024-03-15")
3. Rename the file to: DATE_CLIENT_TYPE.pdf
4. Show me what was renamed
Make it a Python script I can run again later.
Watch what happens. Claude will:
- Think about what you need
- Write a Python script
- Create the file
- Possibly run it to test
Understanding What Claude Built
After Claude creates the script, ask:
Explain what this script does, step by step, in plain English
Claude will walk you through the code. You don’t need to understand the programming syntax—you need to understand the logic:
- Find files — The script looks for all
.pdffiles - Loop through them — For each file, it does something
- Ask questions — It prompts you for information
- Build new name — It combines your answers into a filename
- Rename — It actually changes the file’s name
This pattern—find, loop, transform—appears in almost every automation you’ll build.
Running Your Tool
Claude probably already ran the script, but let’s do it manually to understand the process:
Run the renaming script
The script will show you each file and ask for details. Try it with your test files:
Current file: scan001.pdf
Client/Case name: Smith v Jones
Document type: Complaint
Date (YYYY-MM-DD): 2024-03-15
Renamed to: 2024-03-15_Smith-v-Jones_Complaint.pdf
Repeat for each file.
Checking the Results
After renaming, verify:
Show me all files in this folder now
You should see your beautifully organized files:
2024-03-15_Smith-v-Jones_Complaint.pdf
2024-03-18_Smith-v-Jones_Motion-to-Dismiss.pdf
2024-03-20_Acme-Corp_Contract.pdf
...
What You Just Did
Let’s pause and recognize what happened:
- You described a problem in plain English
- AI wrote a solution you couldn’t have written yourself
- You ran it and got real results
- You have a reusable tool for next time
This is vibe coding. You didn’t learn Python. You learned to describe what you need clearly enough that AI could build it.
Making It Better
Now let’s improve the tool. Ask Claude:
Update the script to also:
- Skip files that are already in the correct format
- Create a log of all renames
- Handle spaces in names by replacing them with hyphens
Claude will modify the script. This is the iteration cycle: build something basic, then refine it.
Trying Different Inputs
Test edge cases. Run the script again with unusual inputs:
- What happens if you leave a field blank?
- What if you enter a date in the wrong format?
- What if two files would get the same name?
Note what breaks. Then ask Claude to fix it:
The script crashes if I leave the date blank.
Make it use today's date as a default instead.
The Feedback Loop
You’ve just learned the core pattern of building with AI:
Describe → Build → Run → Check → Improve → Repeat
- Describe what you want in plain language
- Build — Claude writes the code
- Run — Execute and see what happens
- Check — Does it work? What’s wrong?
- Improve — Ask for changes
- Repeat — Until it does what you need
Most of your time isn’t writing code. It’s thinking about what you actually need and testing whether you got it.
Saving Your Work
Your script is saved in the folder. You can run it anytime:
python rename_files.py
Or ask Claude to run it:
Run the file renamer script
What You’ve Built
You now have:
- ✅ A working file renaming tool
- ✅ Experience with the describe → build → test cycle
- ✅ Understanding of how AI translates instructions into code
- ✅ A reusable script for future use
Try This
Before the next lesson, try building a variation:
Create a script that organizes files into folders by year,
based on the date in the filename (if it has one) or the
file's modification date (if it doesn't).
See what Claude builds. Run it. Improve it.
Next Lesson
You’ve built your first automation by describing what you want. But how do you describe things well? The next lesson covers the art of talking to AI that builds—how to be specific, how to handle ambiguity, and how to get what you actually need on the first try.