Back to course
Your First Build
Lesson 2 of 10
Free

Your First Automation

Build a tool that renames messy files into organized, consistent names. Your first taste of directing AI to build for you.

20 min read
Share

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:

  1. Looks at files in a folder
  2. Asks you what each file is (client name, document type, date)
  3. 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:

  1. Find files — The script looks for all .pdf files
  2. Loop through them — For each file, it does something
  3. Ask questions — It prompts you for information
  4. Build new name — It combines your answers into a filename
  5. 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:

  1. You described a problem in plain English
  2. AI wrote a solution you couldn’t have written yourself
  3. You ran it and got real results
  4. 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
  1. Describe what you want in plain language
  2. Build — Claude writes the code
  3. Run — Execute and see what happens
  4. Check — Does it work? What’s wrong?
  5. Improve — Ask for changes
  6. 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.