Ever felt like a robot just cleaning up folders? Like when you download hundreds of design assets or photos, and their names are all messy like IMG_999_final_af_v2.jpg. Or worse, your “Downloads” folder is full of junk files from the stone age, making your SSD scream in pain?
If you’re still renaming or deleting one by one using right-click… honestly, you’re wasting precious time.
In this article, I’ll show you how to create simple PowerShell scripts so your Windows works by itself. You just sit back with your coffee, and let my script handle the rest.
PowerShell: Not Just a Blue Screen Thing
Many ask, “Why not just use CMD, dude?”. Well, PowerShell is way smarter than CMD. It can read objects. So if you want to find files larger than 1GB or files that haven’t been opened in a year, PowerShell can find them super easily.
Auto-Rename: Make Your Folder Aesthetic
Let’s say you have a folder with camera photos named DSC001, DSC002, etc. And you want to rename them to Cool_Project_001.
Smash this code:
# Change this path to your target folder!
$folderPath = "C:\Users\You\Documents\Project_Assets"
# Get all files, then rename them
Get-ChildItem -Path $folderPath | ForEach-Object {
$newName = $_.Name -replace "DSC", "Cool_Project"
Rename-Item -Path $_.FullName -NewName $newName
} Why this works:
Get-ChildItem: This is how you tell PowerShell, “Hey, look inside this folder.”-replace: This is the magic command to swap garbage words with the words you want.
Auto-Delete: Throw Away Your Ex… I mean, Junk Files!
I’m sure your Temp or Downloads folder is a ghost town. Well, we can create a script that automatically deletes files that haven’t been touched in more than 30 days.
Copy-Paste this code:
# Your junk folder path
$trashPath = "D:\Downloads\Trash"
$daysLimit = 30
# Find moldy files, then delete them!
Get-ChildItem -Path $trashPath -Recurse | Where-Object {
$_.LastWriteTime -lt (Get-Date).AddDays(-$daysLimit)
} | Remove-Item -Force If you’re afraid of deleting the wrong thing, add -WhatIf at the end of the Remove-Item line. PowerShell will then just show, “Here are the files I WOULD delete,” without actually deleting anything. So you can double-check first.
How to Make It Run Automatically (No More Clicking)
The scripts above won’t be useful if you have to open and run them manually every day. You need to use Windows’ built-in Task Scheduler:
Step 1
Search for Task Scheduler in the Start Menu.
Step 2
Choose Create Basic Task, give it a name like “Folder Cleanup”.
Step 3
Under Action, select Start a Program.
Step 4
In Program/script, enter: powershell.exe.
Step 5
In Add arguments, enter:
-ExecutionPolicy Bypass -File "C:\Path\To\Your\Script.ps1".
Done! Now every morning when you turn on your PC, that script will run automatically in the background.
Conclusion
Still doing things manually these days? Such a waste of your skills. With a little automation like this, you’re one step closer to becoming an efficient power user.