Step-by-step
📁 GitHub Copilot
GitHub
📘 Step-by-step 📘 GitHub Copilot↗ GitHub Copilot · Official sitebeginner 🏠 Everyday life

Safely Rename a Batch of Photos with a GitHub Copilot Script

Use Copilot in VS Code to generate a small Python script, test it on copies, then rename your real photos in one click.

This guide was written by AI. It passed automated fact and quality checks, and our editor spot-checks published guides every day.

See AI World HQ first on GoogleAdd us as a preferred source and our stories show up higher in Google’s Top Stories.Add on Google

By the end of this short guide, you'll have asked Copilot to write a small Python script, tested it on copies of your photos, and renamed an entire folder without typing a line of code yourself. If you have a folder of vacation shots named IMG_4829.jpg, IMG_4830.jpg, and so on, this is for you.

💡 Tip: tap a step’s number when you finish it — a green tick appears and your browser remembers how far you got.

✅ Before you start
  • A computer running Windows, macOS, or Linux.
  • VS Code installed — the free code editor from Microsoft (download from code.visualstudio.com).
  • The GitHub Copilot extension installed in VS Code, with a Copilot account signed in. Copilot offers a free tier and paid plans; check the official GitHub page for current availability and which features each tier includes.
  • Python installed on your computer (download from python.org). Python is the language your script will be written in — think of it as plain English instructions for your computer.
  • A folder of photos you'd like to rename, plus enough free disk space to make a copy. The whole task takes about 15 minutes.
1
Step 1 of 6

Make a working copy of your photos

Right-click your photo folder in your file manager, choose Copy, then Paste somewhere easy to find, like your Desktop. Rename the copy to something like photos-test. This is the folder you'll experiment on.

On macOS, you can also select the folder and press Option-drag to duplicate it. On Windows, hold Ctrl while dragging. You'll see a second folder appear next to your originals, with all the same files inside.

Some file managers hide the "Paste" option inside an Edit menu; look there if right-click doesn't show it.

🔄 If it looks different

**** If your photos live in cloud storage like Google Drive or iCloud, the same Copy/Paste idea works — just make sure the copy finishes syncing before you start renaming anything.

✅ You'll know it worked when

you see two folders: your untouched originals and a clearly named test copy.

Next step ↓
GitHub CopilotCopy
✏️ Sketch — your screen may look a little different
2
Step 2 of 6

Open the test folder in VS Code

Open VS Code, then go to File → Open Folder… and pick your new photos-test folder. VS Code's left sidebar (called the Explorer) now lists every photo in the folder.

A workspace in VS Code is simply the folder you opened — think of it as putting that folder "on your desk" so the editor can see everything inside it. Nothing is moved or copied; VS Code is just looking.

If the Explorer sidebar is hidden, use View → Explorer to bring it back.

🔄 If it looks different

**** On the VS Code welcome screen, there's a big Open Folder button you can click instead.

✅ You'll know it worked when

the names of your test photos appear in the left sidebar.

Next step ↓
GitHub CopilotFile → Open Fo…
✏️ Sketch — your screen may look a little different
3
Step 3 of 6

Open the Copilot chat panel

In VS Code, open the Copilot Chat panel. The keyboard shortcut is Ctrl+Alt+I on Windows and Linux, or Cmd+Shift+I on macOS. A chat window appears — usually on the side of the window.

Copilot is an AI coding assistant: you describe what you want in plain language, and it suggests code. You don't have to understand the code right now — that's the whole point of having an AI helper.

Some older versions put Copilot under File → Preferences instead.

🔄 If it looks different

**** If the shortcut doesn't open anything, look for a small chat-bubble icon in the VS Code sidebar, or use the menu View → Copilot Chat.

✅ You'll know it worked when

a chat box is visible with a blinking text cursor, ready for your message.

Next step ↓
GitHub CopilotCopilot Chat
✏️ Sketch — your screen may look a little different
4
Step 4 of 6

Describe your renaming task in plain English

Click into the chat box and type what you want. Be specific about the folder, the file types, and the new naming pattern. Copilot reads your message and proposes a Python script in the chat.

The more clearly you describe the rule, the better the script will be. If your rule is "rename to vacation-001.jpg, vacation-002.jpg, …", say that exactly. If you want the date taken included, ask for that too.

💬 Example`Write a Python script that renames every .jpg and .png file in the current folder to "vacation-2024-001.jpg", "vacation-2024-002.jpg", and so on. Skip files that already match this pattern.`

If it offers several code blocks, pick the one that looks closest to what you asked for and ignore the rest.

🔄 If it looks different

**** Copilot might ask a follow-up question like "What folder should I use?" — just answer in the same chat.

✅ You'll know it worked when

a code block appears in the chat with a Python script inside it.

Next step ↓
GitHub CopilotWrite a Pythonscript that renamesevery .jpg and .png…
✏️ Sketch — your screen may look a little different
5
Step 5 of 6

Save the script and run it on the test folder

When Copilot shows a script, look for a small "Insert into new file" button above the code (or a similar option like "Apply" or "Copy"). Click it, and VS Code creates a new file. Save this file inside your test folder as rename.py.

Now open VS Code's built-in terminal from the top menu: Terminal → New Terminal. A text panel slides up from the bottom. Type python rename.py and press Enter.

The terminal is a text-based way to talk to your computer directly — instead of clicking icons, you type commands and read text replies.

On Windows, you may need to install Python from python.org and tick "Add Python to PATH" during setup for the command to work.

🔄 If it looks different

**** If python isn't recognized, try python3 rename.py instead — that's more common on macOS and Linux.

✅ You'll know it worked when

the terminal shows your photos being renamed one by one, and the file list in the Explorer updates.

Next step ↓
Save the script and run it on the test folder
6
Step 6 of 6

Verify, then run the same script on your real folder

Open the test folder in your regular file viewer (Finder, Explorer, or Files) and check the new names. Open a few photos to make sure none are broken — the picture files themselves shouldn't change, only their names.

If the names look right, you have two safe options: copy your rename.py script into your real photo folder and run it there, or ask Copilot to adjust the script so it points to a different folder. Either way, your originals stay untouched.

If the names look wrong, go back to Step 4 and ask Copilot to fix the rule, then re-test on the test folder before touching real files.

🔄 If it looks different

**** If a photo won't open, the file may have been partially affected — restore it from your test copy or your originals.

✅ You'll know it worked when

your real photo folder shows the clean new names, and every photo still opens normally.

Verify, then run the same script on your real folder
⚠️ Common mistakes
  • Skipping the test folder. It's tempting to point the script straight at your real photos, but one wrong rule can scramble hundreds of filenames at once. Always run the script on copies first, then on the real folder only after you're sure the names are right.
  • Running the script twice without changing the names. The second run will keep building on your filename pattern (vacation-2024-001.jpg could become vacation-2024-001-001.jpg). Either move the renamed files out, or include the "skip if already named" rule in your prompt.
  • Trusting Copilot's first answer without reading. Copilot is helpful but not perfect. If the script does something you didn't ask for — like deleting files or changing the file extension — rewrite your prompt to be more specific and try again on the test folder.
🚀 Try it now

Open your test folder in VS Code, open the Copilot chat, and paste this exact message.

💬 Example`Write a Python script that lists every .jpg file in the current folder and renames them to "sample-001.jpg", "sample-002.jpg", in the order they appear. Print the new names before doing it.`

Run it on a tiny folder of 3 to 5 test files. Seeing those photos rename themselves is the moment this stops feeling like magic and starts feeling like a tool you control.

🎯 Next guideAdd helpful comments to your code with GitHub Copilot – beginner guideA friendly step‑by‑step walkthrough that shows anyone how to get GitHub Copilot to write plain‑language comments for any line of code

❓ Quick questions

How long does this take?

About 6 minutes — the guide has 6 steps, and you can tick each one off as you go.

Which tool do I need?

This guide uses GitHub Copilot — but the approach works very similarly in other AI assistants.

Do I need to prepare anything?
  • A computer running Windows, macOS, or Linux.
  • VS Code installed — the free code editor from Microsoft (download from code.visualstudio.com).
  • The GitHub Copilot extension installed in VS Code, with a Copilot account signed in. Copilot offers a free tier and paid plans; check the official GitHub page for current availability and which features each tier includes.
  • Python installed on your computer (download from python.org). Python is the language your script will be written in — think of it as plain English instructions for your computer.
  • A folder of photos you'd like to rename, plus enough free disk space to make a copy. The whole task takes about 15 minutes.
What mistakes should I avoid?
  • Skipping the test folder. It's tempting to point the script straight at your real photos, but one wrong rule can scramble hundreds of filenames at once. Always run the script on copies first, then on the real folder only after you're sure the names are right.
  • Running the script twice without changing the names. The second run will keep building on your filename pattern (vacation-2024-001.jpg could become vacation-2024-001-001.jpg). Either move the renamed files out, or include the "skip if already named" rule in your prompt.
  • Trusting Copilot's first answer without reading. Copilot is helpful but not perfect. If the script does something you didn't ask for — like deleting files or changing the file extension — rewrite your prompt to be more specific and try again on the test folder.

Keep reading

Was this helpful?

✦ Generated by AI in AI World HQ's automated newsroom, written in plain language. Checked by automated fact and quality gates, and our editor spot-checks published guides every day. Spot a mistake? Use the buttons above.

📘 Prefer it in one file? Photos and Images: The AI Pack (20 guides, free printable PDF)

← Back to all stories