GitHub Copilot CLI Challenge Submission: Smart File Organizer
Project Name: Smart File Organizer
Project Type: Productivity Utility
Project Description
Smart File Organizer is a simple PowerShell utility that automatically organizes files in any folder by their file extensions. When run, it creates subfolders for each file type (e.g., Documents, Images, Videos) and moves files into their respective folders. This reduces clutter and helps maintain a clean working directory instantly.
This project demonstrates how GitHub Copilot CLI can accelerate development directly from the terminal. I used Copilot to suggest, explain, and improve my PowerShell script in real-time, saving time and enhancing code quality.
Key Features
- Automatically sorts files into subfolders based on file extensions.
- Avoids overwriting files with the same name.
- Provides basic error handling for inaccessible files.
- Fully generated and enhanced using GitHub Copilot CLI prompts.
How Copilot CLI Helped
- Suggest: Copilot generated the initial PowerShell script to organize files.
- Explain: Copilot explained each part of the script, helping me understand the logic and structure.
- Fix/Improve: Copilot improved the script to handle file conflicts and added error handling automatically.
How to Run
- Open PowerShell in the project folder.
- Run the script:
.\smart-organizer.ps1
- Files in the current folder will be automatically organized into subfolders.
Screenshots
- Copilot CLI Suggest Output
- Copilot CLI Explain Output
- Copilot CLI Fix/Improve Output
- Script Execution Confirmation (
Files organized successfully!)
This project demonstrates hands-on usage of GitHub Copilot CLI, showcasing how AI can directly assist developers in writing, understanding, and improving code without leaving the terminal.
Smart File Organizer Script
$sourcePath = Get-Location
Get-ChildItem -Path $sourcePath -File | ForEach-Object {
$extension = $_.Extension.TrimStart(".").ToUpper()
if (-not $extension) {
$extension = "NO_EXTENSION"
}
$destinationFolder = Join-Path $sourcePath $extension
if (-not (Test-Path $destinationFolder)) {
New-Item -ItemType Directory -Path $destinationFolder | Out-Null
}
$destinationPath = Join-Path $destinationFolder $_.Name
if (-not (Test-Path $destinationPath)) {
Move-Item $_.FullName $destinationFolder
}
}
Write-Host "Files organized successfully!"
DEV Badge Note: All screenshots and terminal outputs are included to verify usage of GitHub Copilot CLI.
Submitted by: John Oboh
Gmail: saziblow@gmail.com
Top comments (0)