Organize a Folder with PowerShell and Git
Sort files into folders by type, track changes with Git, and audit the cleanup.
Introduction
30 Second Summary
Everyone has that one folder stuffed with random downloads, old installers, and files you swore you'd sort "later." The mess grows until finding anything feels impossible.
In this project, you will use PowerShell commands to audit, sort, and clean up a practice folder. Git tracks every change so you can undo mistakes instantly.
What You'll Build
A cleaned-up, git-tracked folder with a before/after audit report proving exactly what changed.
By the end of this project, you'll have:
- A git repository with safety-net commits at each cleanup stage, letting you revert the entire folder to any previous state.
- A CLAUDE.md file that sets the rules for how an AI assistant should behave in this project.
- A before/after audit file showing grouped file counts and listings, so you can see exactly what you organized.
- Secret Mission: Write a reusable PowerShell script that automates the audit and organize steps for any folder you point it at.
Are there any prerequisites?
None. This project includes setup verification for all required tools. You just need a Windows machine with VS Code and Git installed.
Navigate to Your Project Folder
Before you can organize any files, you need to be working in the right folder with the right tools at your fingertips.
In this step, you'll open the target folder in VS Code, launch a PowerShell terminal inside it, and confirm that both Git and PowerShell are responding to your commands.
In this step, get ready to:
- Close any existing project in VS Code.
- Open the target folder and launch the integrated terminal.
- Verify that git and PowerShell are working in your terminal.
Close your current project
Starting with a clean slate prevents confusion between files from different projects.
- In VS Code, click File in the top menu bar.
- Click Close Folder to close whatever you currently have open.
You should now see the VS Code Welcome tab or an empty editor with no files in the sidebar.
Open the target folder
VS Code works best when you open an entire folder rather than individual files. Opening the folder sets your terminal's starting location automatically.
- Click File in the top menu bar.
- Click Open Folder.
- Navigate to C:\Users\sulav\Documents\Github\downloads folder-clean up project and click Select Folder.
What should I see?
The Explorer sidebar on the left should now show all the files in your messy folder. You'll see the folder name at the top of the sidebar.
- Open the integrated terminal by pressing Ctrl+` (that's the backtick key, usually above Tab).
- Confirm the terminal prompt starts with PS followed by the path to your folder.
Terminal not showing PowerShell?
If your terminal prompt doesn't start with PS, you might be in Command Prompt or another shell. Click the dropdown arrow next to the + button in the terminal panel and select PowerShell.
help me switch my VS Code terminal to PowerShell
Verify your tools are ready
You need two tools working in this terminal: git for version control, and PowerShell for file manipulation. Time to confirm both are responding.
- For git: most CLI tools accept a flag to print their version. It's two dashes followed by a common English word. Try typing it and pressing Enter.
- For PowerShell: there's a built-in automatic variable that holds version info. It starts with $PS and ends with Table. Type it and press Enter to confirm you're on PowerShell 5.1 or later.
Give it a try on your own first. If you get stuck, check your work below.
✔️ I'll try it first
Go for it. You're looking for a version number from each command. If you see one, your tool is ready.
ⓧ Let me check my work
Here are the two commands you should have run:
git --version
This prints something like git version 2.x.x. Any version number means git is working.
$PSVersionTable
This prints a table. Look for the PSVersion row. It should show 5.1 or higher.
Why verify in this terminal?
Even though these tools are installed on your system, confirming them inside VS Code's integrated terminal ensures they're accessible from the exact environment where you'll be running all your commands.
Your folder is open, your terminal is live, and your tools are confirmed. Next up, you'll create a CLAUDE.md file that sets the rules for how AI assistants should behave in this project.
Create a CLAUDE.md File
Your folder is open and your tools are verified. Now it's time to set boundaries for any AI assistant that helps you organize files.
A CLAUDE.md file is a plain Markdown file that gives persistent instructions to an AI assistant. You'll create one at the root of your project so the AI knows what it can and cannot do with your files.
In this step, get ready to:
- Understand what a CLAUDE.md file is and how AI assistants use it.
- Create a CLAUDE.md file with rules that prevent AI from reading file contents or moving files out of scope.
Understand what CLAUDE.md is
CLAUDE.md is a rules sheet you place at the root of a project. It gets loaded at the start of every AI conversation about that folder.
Tools like Claude Code and Cursor read this file automatically. Any rules you write here apply to every session without you repeating them.
What is CLAUDE.md?
Think of it as a persistent prompt. Instead of typing "don't read my files" at the start of every conversation, you write that rule once in CLAUDE.md and the AI follows it automatically.
For this project, you'll encode rules that prevent the AI from opening your personal files or scattering folder contents outside your working directory.
Create the file and write your rules
- In VS Code's Explorer panel (left sidebar), right-click in the empty space below your files.
- Select New File.
- Name the file CLAUDE.md and press Enter.
The file opens in the editor. Now think about what constraints matter for a folder-cleanup project where AI should never peek inside your files.
The key rules you want to encode are:
- Never read file contents. Only use file names and extensions to make decisions.
- Existing folders are atomic. Do not scramble or reorganize the contents of any pre-existing subfolder.
- All organization must happen within this folder or its subfolders. Nothing moves outside.
- Always commit to Git before making destructive changes like bulk deletions or moves.
- If a file's name is ambiguous, leave it in place rather than guessing its purpose.
Structure your rules using Markdown headers and bullet points. Keep it under 30 lines. Give it a try, or check the help tab for a ready-made version.
✔️ I'll give it a go!
Write your own version of the rules using the list above as a guide. Once you're happy with it, save the file and move on.
ⓧ Maybe a little help...
Copy this into your CLAUDE.md file:
# Project Rules
## Purpose
This project organizes files in a downloads folder by extension and name patterns.
## Rules for AI Assistants
- **Never read file contents.** Use only file names and extensions to make decisions.
- **Existing folders are atomic.** Do not scramble or reorganize the contents of any pre-existing subfolder.
- **Stay in scope.** All organization must happen within this folder or its subfolders. Do not move files outside this directory.
- **Commit before destructive changes.** Always ensure a git commit exists before deleting or moving files in bulk.
- **No assumptions about file purpose.** If a file's name is ambiguous, leave it in place rather than guessing.
What do these rules do?
- "Never read file contents" ensures the AI organizes purely by file names and extensions. Your personal documents stay private.
- "Existing folders are atomic" prevents the AI from digging into subfolders and scattering their contents.
- "Commit before destructive changes" pairs with Git to give you a safety net. If anything goes wrong, you can revert.
- Save CLAUDE.md by pressing Ctrl+S.
- Confirm the file appears in the Explorer sidebar. You should see CLAUDE.md listed among your other files.
Don't see CLAUDE.md in the sidebar?
- Make sure you saved the file. An unsaved file shows a dot on its tab in VS Code.
- Check that the file name is exactly CLAUDE.md (all caps for CLAUDE, lowercase for .md). A typo in the name won't break anything, but AI tools look for this exact filename.
Still stuck? Ask for help.
Why write rules down instead of just remembering them?
This is a real workflow that developers use with AI coding tools. When you later clean your actual Downloads folder with AI assistance, your CLAUDE.md prevents the AI from accidentally reading personal documents or scattering files across your filesystem.
It's a guardrail you set once and benefit from every session.
Your rules are written. Next, you'll initialize a Git repository so every change you make from here on has a safety net you can revert to.
Create a Git Safety Net
Your CLAUDE.md is ready with clear rules for how AI assistants should behave in this folder.
Now you need a safety net before you start moving and deleting files. Git lets you take snapshots of your folder at any point. If you accidentally move or delete something wrong, you can restore the entire folder to a previous snapshot with one command.
In this step, get ready to:
- Initialize a git repository in your project folder.
- Stage and commit all files as your "before" snapshot.
- Verify you can see your commit in the history.
Initialize a repository
Git needs to be told "start tracking this folder." The command creates a hidden .git folder that stores all your version history.
- Figure out the initialization command and run it in your terminal. It's two words: git followed by a short word that means "start" or "begin a new repository."
- After it runs, check what git sees by running the command that shows your current state (what's tracked and what's not).
Ready to try it yourself, or would you like the answer?
✔️ I'll give it a go!
Go for it. You're looking for a two-word command to initialize, then another two-word command to check the status. Both start with git.
ⓧ Maybe a little help...
- Initialize the repository by running:
git init
- Check the current state by running:
git status
What should I see?
After git init, you'll see a message confirming the repository was initialized in the .git/ directory.
After git status, you'll see everything listed as "untracked" in red text, including your CLAUDE.md. This means git knows the files exist but isn't tracking them yet.
What is a git repository?
A git repository is a hidden .git folder that stores the full history of changes to your project. Every time you "commit," git saves a snapshot you can return to later.
The folder itself looks the same. Git works invisibly in the background, tracking what changed between each snapshot.
Take your "before" snapshot
Git works in two steps: stage (tell git what to include in the next snapshot), then commit (save that snapshot permanently).
- Stage everything for your first commit. The staging command takes a path argument. Think about what single character represents "the current directory" in a terminal.
- After staging, commit with a descriptive message. The commit command has a -m flag that lets you write the message inline. Use the message initial state before cleanup.
Give it a shot, or check below if you need help.
✔️ I'll give it a go!
You need two commands. The first stages files (hint: the path character is a dot). The second commits them with a message flag.
ⓧ Maybe a little help...
- Stage all files in the current directory by running:
git add .
- Commit the staged files with your message by running:
git commit -m "initial state before cleanup"
What does staging mean?
Staging is like placing items in a box before sealing it. git add . tells git "include everything in the current directory in my next commit." The dot (.) means "this directory and everything inside it."
The commit then seals the box with a label (your message) so you can find it later. You now have a permanent record of how the folder looked before any cleanup.
Seeing an error about identity?
If git asks you to set your name and email before committing, run these two commands with your own details:
git config --global user.email "your-email@example.com"
git config --global user.name "Your Name"
Then run your git commit command again.
Help me fix my git commit error
Verify your safety net
You should now have one commit in your history. Time to confirm it worked.
- Run the git command that shows commit history. It's two words: git followed by the word for "record" or "history."
Try it yourself, or check below.
✔️ I'll give it a go!
Look for a command that shows your commit history. You should see your commit message initial state before cleanup in the output.
ⓧ Maybe a little help...
- View your commit history by running:
git log
You should see one entry with your commit message, the author name, and a timestamp.
Why does this matter?
This single commit is your undo button for the entire project. If anything goes wrong during cleanup, running git reset --hard HEAD will restore every file in this folder to exactly how it looks right now.
You will never lose a file permanently as long as you committed it first. That's the power of working with a safety net.
Don't see your commit?
If git log shows nothing, your commit didn't go through. Run git status to check. If files are still listed as "untracked," you skipped the staging step. Run git add . first, then git commit -m "initial state before cleanup".
Help me figure out why my commit didn't work
Your safety net is in place. Next up, you'll use PowerShell to audit everything in this folder and save a "before" snapshot to a text file.
Generate and Save the "Before" Audit
Your git safety net is in place. If anything goes wrong from here, you can always revert to that first commit.
Before you start moving or deleting anything, you need a clear picture of what's actually in this folder. In this step, you'll explore the folder's contents using PowerShell cmdlets, then save that snapshot to a permanent audit file.
In this step, get ready to:
- Explore the folder contents using Get-ChildItem.
- Group files by extension to identify cleanup categories.
- Save the "before" state to an audit text file.
List all items and understand what you're working with
PowerShell's cmdlet for listing items in a directory is Get-ChildItem. It works like a spotlight on your folder, showing you everything inside.
- Run the cmdlet without any parameters to see everything in your folder:
Get-ChildItem
You should see a list of both files and folders printed in your terminal.
- Now try it with the -File flag to see only files:
Get-ChildItem -File
- Try it with -Directory to see only folders:
Get-ChildItem -Directory
What do these flags do?
The -File flag filters the output to only show files. The -Directory flag filters to only show folders.
Separating files from folders helps you plan. Files are what you'll sort into categories. Folders are "atomic" per your CLAUDE.md rules and stay untouched.
Group files by extension
Knowing what files exist is helpful, but knowing how many of each type you have is your cleanup roadmap. PowerShell lets you pipe the output of one cmdlet into another using the | character.
- Pipe your file listing into Group-Object to see a count per extension type by running this command:
Get-ChildItem -File | Group-Object -Property Extension
What does this command do?
The | (pipe) takes the output of Get-ChildItem -File and feeds it directly into Group-Object.
Group-Object -Property Extension sorts all those files into buckets based on their file extension. You'll see something like "5 .pdf, 3 .exe, 2 .zip" depending on what's in your folder. This tells you exactly which category folders you'll need later.
You should see a table with a Count column and a Name column (the extension). This is your cleanup roadmap.
- Now pipe the file listing into Sort-Object to see files sorted alphabetically by name:
Get-ChildItem -File | Sort-Object -Property Name
What should I look for?
Sorting alphabetically makes patterns jump out. Look for files with "(1)" or "(2)" in the name (duplicate downloads). Look for files named "Untitled" or "New Document" (likely junk). Look for versioned files like "report_v2" next to "report_v3" (keep the latest, delete the rest).
Save the audit to a file
You've seen what's in the folder, but terminal output disappears when you close the window. You want this "before" state recorded permanently so you can compare it to the "after" state later.
- Send your grouped-by-extension output to a file called _audit.txt by running this command:
Get-ChildItem -File | Group-Object -Property Extension > _audit.txt
What does > do?
The > operator is the redirection operator. Instead of printing output to the terminal, it sends the output to a file. If the file doesn't exist, it creates it. If it already exists, it overwrites it completely.
- Now append the full sorted file listing below the extension summary by running:
Get-ChildItem -File | Sort-Object -Property Name >> _audit.txt
What does >> do differently?
The >> operator appends to the file instead of overwriting it. Your _audit.txt now contains two sections: the extension group counts at the top, and the full alphabetical file listing below.
- Confirm the file was created by running:
Get-ChildItem _audit.txt
You should see _audit.txt listed with a file size greater than 0 bytes.
- Click on _audit.txt in the VS Code **Explorer** sidebar to open it.
- Verify you can see extension group counts at the top and a full file listing below.
Don't see _audit.txt in the sidebar?
Make sure you ran the commands in the correct terminal. Your PowerShell prompt should show the path to your project folder. If you accidentally opened a new terminal, it may be pointing to a different directory.
If the file is empty (0 bytes), your folder might not contain any files at the top level. Try running Get-ChildItem -File by itself to confirm there are files to list.
Help me troubleshoot my _audit.txt file
You now have a permanent record of what your folder looks like before any changes. Next up, you'll analyze this data to decide exactly which files go where and which ones are junk.
Identify What Cleanup Is Needed
Your audit is saved and your Git safety net is in place. Now you need a plan before you start moving or deleting anything.
You'll read your audit output to decide three things: which extension groups deserve their own subfolder, which files are junk based on their names alone, and which existing folders to leave untouched.
In this step, get ready to:
- Identify file categories by reading extension groups.
- Spot junk files by name patterns.
- Review existing folders and decide their fate.
Identify categories by extension
Each extension group with more than one file probably deserves its own subfolder. Your _audit.txt already contains the grouped output you need.
- Open _audit.txt in VS Code by clicking it in the Explorer sidebar.
- Look at the extension groups and their counts at the top of the file.
- For each extension that appears more than once, write down a category name for it.
Here are common category groupings to consider:
- Documents: .pdf, .docx, .txt, .xlsx.
- Images: .png, .jpg, .gif, .svg.
- Installers: .exe, .msi.
- Archives: .zip, .rar, .7z, .tar.gz.
- Code: .py, .js, .html, .css.
What if my extensions don't match these categories?
Your folder will likely have different extensions than the examples above. The principle stays the same: any extension group with multiple files gets its own subfolder.
If an extension only appears once, you can either put it in the closest matching category or leave it in the root folder for now.
Identify junk by file name patterns
You never need to open a file to know it's junk. The file name tells you everything.
- Scroll through the full file listing in _audit.txt (the section below the extension groups).
- Look for files with "(1)" or "(2)" in the name. These are duplicate downloads.
- Look for files named "Untitled" or "New Document". These are throwaway files that were never properly saved.
- Make a mental note of which files you'll delete in a later step.
Why not just open the files to check?
Your CLAUDE.md rules say "never read file contents." This applies to you too, not just AI assistants. The whole point of this project is to organize by name and extension alone.
If a file name is ambiguous and you can't tell whether it's junk, leave it in place. That's the safer choice.
List existing folders
Your _audit.txt only captured files. You also need to know what folders already exist so you don't accidentally create duplicates or scramble their contents.
- List only the folders in your directory by running this command:
Get-ChildItem -Directory
You should see a list of any subfolders that already exist inside your project folder.
- For each folder in the output, decide: keep it as-is, or mark it for deletion if you recognize it as junk from the name alone.
Why do existing folders stay untouched?
Your CLAUDE.md declares existing folders as "atomic." That means you treat each folder as a single unit. You either keep the whole folder or delete the whole folder.
You never reach inside an existing folder to reorganize its contents. That prevents accidentally breaking something that was already organized in its own way.
Write your plan down
Before moving on, jot down your decisions somewhere (a sticky note, a comment in your terminal, or just a mental list). You'll need three things: the subfolder names you'll create, the files you'll delete, and the existing folders you'll remove. Having this clear before you act makes the next steps faster.
You've got your cleanup plan mapped out. Next, you'll create the category folders and start moving files into them.
Create Category Folders and Organize
You've identified your file extension groups and know which categories make sense for your folder. Now it's time to put that plan into action.
In this step, you'll create subfolders for each category and move files into them using PowerShell cmdlets. Then you'll lock in the organized state with a Git commit as a new restore point.
In this step, get ready to:
- Create category subfolders with New-Item.
- Move files into their category folders with Move-Item.
- Commit the organized state to git.
Create your category subfolders
The New-Item cmdlet creates new items in PowerShell. For folders, you give it a -Path (the name you want) and set -ItemType to Directory.
- Create one subfolder per category you identified in the previous step by running a command like this:
New-Item -Path "Documents" -ItemType Directory
What does this command do?
- -Path "Documents" sets the name of the new folder.
- -ItemType Directory tells PowerShell to create a folder, not a file.
- Repeat this command for each category you need, changing the name each time. For example, if you have PDFs and ZIPs, you might create "Documents" and "Archives."
- Confirm your new folders exist by running:
Get-ChildItem -Directory
You should see all your new category subfolders listed alongside any folders that already existed.
Folder already exists error?
If PowerShell says the item already exists, that folder was already there from before. Skip it and move on to the next category.
Why is PowerShell telling me the item already exists?
Move files into their category folders
The Move-Item cmdlet moves files from one location to another. It supports wildcards in the -Path parameter, so you can move an entire extension group in one command.
- Move one extension group at a time by running a command like this:
Move-Item -Path *.pdf -Destination Documents
What does this command do?
- -Path *.pdf selects every file with the .pdf extension in the current folder.
- -Destination Documents moves them into the "Documents" subfolder.
- Repeat for each extension group, matching the wildcard pattern to the destination folder (e.g., *.png to "Images", *.exe to "Installers", *.zip to "Archives").
- After each move, confirm the files remaining in the root by running:
Get-ChildItem -File
The list should get shorter each time you move a group. If something looks wrong, remember git reset --hard HEAD will undo everything back to your last commit.
Files didn't move?
- Check that the destination folder name matches exactly what you created with New-Item. Spelling must be correct.
- Make sure you're in the project root, not inside a subfolder. Check your terminal prompt path.
- If no files matched the wildcard (e.g., you have no .pdf files), PowerShell simply does nothing. That's normal.
Why didn't my Move-Item command work in PowerShell?
Commit the organized state
Now that your files are sorted into subfolders, lock in this state with a git commit. This creates a second restore point you can jump back to anytime.
- Stage all changes and commit by running:
git add .
git commit -m "organized files into category folders"
What does this command do?
- git add . stages every change (new folders, moved files) for the next commit.
- git commit -m "organized files into category folders" saves those changes permanently with a descriptive message.
- Verify your commit history by running:
git log --oneline
You should see two commits listed: your original "initial state before cleanup" and the new "organized files into category folders" commit.
Commit says nothing to commit?
- Run git status first. If everything shows as clean, your changes were already committed or no files were actually moved.
- Make sure you ran your Move-Item commands before trying to commit. Git only tracks changes that actually happened on disk.
Why does git say there's nothing to commit after I moved files?
Your files are sorted and locked in with git. Next, you'll clean up the junk files and folders you flagged earlier.
Delete Junk and Finalize
Your files are sorted into category subfolders. The folder is already much easier to navigate. But there's still junk sitting around.
In this step, you'll remove the files and folders you identified as junk based on their names. Duplicate downloads, throwaway files, and folders you recognize as useless will go. Then you'll lock in this clean state with a third git commit.
In this step, get ready to:
- Delete junk files using name-pattern wildcards.
- Delete junk folders with their contents.
- Commit the cleanup to create a third restore point in git.
Delete files you identified as junk
Remember the naming patterns you spotted in Step 5? Files with "(1)" or "(2)" in the name are duplicate downloads. Files named "Untitled" or "New Document" are throwaways. You'll target these by name pattern, not by opening them.
- The cmdlet for deleting items is Remove-Item. It takes a -Path parameter that supports wildcards.
- Delete files matching a junk pattern by running a command like this:
# Example: delete files with "copy" in the name
Remove-Item -Path "*copy*"
What does this command do?
Remove-Item -Path "*copy*" deletes every file in the current directory whose name contains "copy." The asterisks are wildcards that match any characters before and after the word.
Adapt this to your folder. If you spotted files with "(1)" in the name, try *(1)* as your pattern. Work in small batches so you can verify between each deletion.
- After each batch, confirm what's left by running:
Get-ChildItem -File
- You should see fewer files each time you run this. The junk-pattern files you targeted should no longer appear in the listing.
Deleted something you didn't mean to?
This is exactly why you committed before making changes. Run git reset --hard HEAD to restore every file back to the last commit (your organized state). Then try again with a more specific wildcard pattern.
help me figure out a safer wildcard pattern for Remove-Item
Delete any junk folders
Folders you identified as junk in Step 5 need the same treatment. The difference is that folders often have contents inside them.
- Use the same Remove-Item cmdlet with the folder's name as the -Path.
- If the folder has contents, PowerShell will ask you to confirm. To skip that prompt and delete everything inside, add the -Recurse flag. Only use it when you're certain the entire folder is junk.
- Delete a junk folder by running a command like this:
# Example: delete a folder and all its contents
Remove-Item -Path "FolderName" -Recurse
What does -Recurse do?
Without -Recurse, PowerShell will prompt you to confirm before deleting a folder that still has files inside. Adding -Recurse tells PowerShell to delete the folder and everything inside it without asking.
This is a powerful flag. Only use it when you've already confirmed from the folder name that the entire thing is junk.
- After deleting, confirm the folders are gone by running:
Get-ChildItem -Directory
- You should only see your category subfolders remaining. The junk folders you targeted should no longer appear.
Folder won't delete?
If you see a confirmation prompt, you forgot the -Recurse flag. Either type Y to confirm, or press Ctrl+C and rerun the command with -Recurse added.
help me delete a folder that has contents inside it
Commit the cleanup
Your junk is gone. Time to lock in this clean state as a third restore point in Git.
- Stage all changes by running:
git add .
- Commit with a descriptive message by running:
git commit -m "removed junk files and folders"
What does this commit represent?
You now have three restore points in your git history. The first is the original messy state. The second is the organized state (files in category folders). The third is the cleaned state (junk removed).
If you ever need to get back to any of these states, git reset --hard HEAD takes you to the most recent commit. You can also target earlier commits by their hash from git log.
- Verify your full commit history by running:
git log --oneline
- You should see three commits listed, one per line. The most recent ("removed junk files and folders") appears at the top.
Only see two commits?
Run git status to check if you have uncommitted changes. If you see files listed in red or green, you may have forgotten to stage with git add . before committing. Stage and commit again.
help me figure out why my git commit didn't work
Your folder is organized and cleaned. Three git commits give you a full safety net. Next up, you'll generate the "after" audit and compare it with your "before" snapshot to see exactly how much work you've done.
Generate the "After" Audit and Compare
Your folder is now organized and the junk is gone. Three git commits preserve every stage of the cleanup, so you can always jump back.
The final piece is proof of work. You'll append an "after" snapshot to your _audit.txt file so you have a single document showing the before and after state side by side.
In this step, get ready to:
- Append a separator and the "after" state to your audit file.
- Review the before/after comparison in VS Code.
- Commit the final audit report to git and verify your full history.
Append a separator and the "after" state to your audit file
Your _audit.txt already contains the "before" snapshot from earlier. Now you'll append an "after" section below it so both states live in one file.
- Append a separator line to your audit file by running this command:
"=== AFTER CLEANUP ===" >> _audit.txt
What does this command do?
In PowerShell, a string in quotes evaluates as output. The >> operator appends that output to the end of the file instead of overwriting it.
This is different from > (which you used earlier to create the file). The single > overwrites everything. The double >> adds to the end.
- Now append your grouped-by-extension summary by running:
Get-ChildItem -File | Group-Object -Property Extension >> _audit.txt
- Then append a full file listing below it by running:
Get-ChildItem -File >> _audit.txt
What's happening here?
You're running the same two commands you used for the "before" section, but this time appending with >> instead of overwriting with >. The audit file now has a clear before section, a separator, and an after section.
Audit file looks wrong or got overwritten?
If your before section disappeared, you accidentally used > instead of >>. Run git checkout -- _audit.txt to restore the file from your last commit, then re-run the append commands with the double arrow.
help me fix my _audit.txt file
Review your audit file
Now you can see the full before/after comparison in one place.
- In the VS Code Explorer panel (left sidebar), click on _audit.txt to open it.
You should see a clear before section at the top (your original extension counts and file listing), the === AFTER CLEANUP === separator, and the after section showing fewer files now sorted into category subfolders.
What should I see?
The "after" section should have fewer files listed at the root level (since most were moved into subfolders). The extension group counts should also be lower or show different distributions.
Files inside your category subfolders won't appear because Get-ChildItem -File only lists the current directory level by default. That's exactly the contrast you want to see.
Commit the final audit and verify your history
The audit file is your proof of work. Committing it to Git means you'll always have this comparison preserved alongside the folder's full cleanup history.
- Stage all changes and commit with a descriptive message by running these commands:
git add .
git commit -m "added before/after audit report"
- Verify your full commit history by running:
git log --oneline
You should see four commits listed, one per line. Each line is a restore point you can jump back to anytime with git reset --hard HEAD (for the latest) or by referencing a specific commit hash.
What does git log --oneline show?
Each line shows a short commit hash followed by your commit message. You should see something like:
- added before/after audit report
- removed junk files and folders
- organized files into category folders
- initial state before cleanup
The newest commit appears at the top. These four commits are your complete safety net for this project.
Commit failed or missing changes?
If git says "nothing to commit," you may have already committed the audit file in a previous step. Run git status to check whether _audit.txt shows as modified. If it doesn't appear, your append commands may not have changed the file.
help me fix my git commit
Secret mission
Write a Reusable Organize Script
You've organized a folder manually. Now turn those commands into a reusable PowerShell script that can organize ANY folder you point it at. One script to rule them all.
Clean Up Your Resources
Clean Up Your Resources
Decide whether to keep your resources running, pause them to come back later, or delete them entirely.
This project runs entirely locally, so there are no ongoing costs.
Resources you created:
- Git repository (.git folder) in your project directory.
- CLAUDE.md file with project rules for AI assistants.
- _audit.txt file with your before/after audit report.
- organize.ps1 reusable script (Secret Mission).
- Category subfolders containing your organized files.
Keep everything running
No action needed. Choose this if you're still actively building or plan to use this folder as your permanent organized state.
- Your folder stays organized with full git history intact.
- You can run git log --oneline anytime to see your commit history.
- Your organize.ps1 script is ready to use on other folders.
- PowerShell, Git, and VS Code remain installed on your machine (all were pre-existing tools).
Pause - I'll come back to this later
Since everything is local with no running processes, there's nothing to pause. Your project is already in a resting state.
- Close the folder in VS Code by going to File > Close Folder.
- When you come back, reopen the folder with File > Open Folder and your git history and all files will be exactly as you left them.
Delete - I don't want to use this again
Remove all project artifacts and revert to the original folder state. You have two options depending on what you want.
Option 1: Revert the folder to its original messy state (undo all organization).
- In your PowerShell terminal, run this command to reset to your first commit:
- This restores the folder to the exact state it was in before you organized anything.
git reset --hard HEAD~3
- Then remove the git tracking and project files by running:
Remove-Item -Path .git -Recurse -Force
Remove-Item -Path CLAUDE.md
Remove-Item -Path _audit.txt
Remove-Item -Path organize.ps1
Option 2: Keep files organized but remove project artifacts only.
- Run this to remove git tracking and the project-specific files while keeping your organized folder structure:
Remove-Item -Path .git -Recurse -Force
Remove-Item -Path CLAUDE.md
Remove-Item -Path _audit.txt
Remove-Item -Path organize.ps1
- Your category subfolders and organized files remain in place, but git history is gone.
Nice Work!
Nice Work!
You just took a messy folder, set up AI guardrails, audited it, organized it, cleaned it up, and produced a before/after report to prove it. All tracked by Git.
You've learned how to:
- Created a CLAUDE.md file that sets persistent rules for AI assistants working in your project.
- Built a git safety net with commits at each cleanup stage, giving you restore points to revert to if anything goes wrong.
- Used PowerShell cmdlets like Get-ChildItem, Group-Object, New-Item, Move-Item, and Remove-Item to audit, organize, and clean a folder entirely from the terminal.
- Wrote a reusable organize.ps1 script that automates the audit and organization steps for any folder you point it at.
Ready to quiz yourself?