File Management

Scheduled File Organizer: Auto-Sort Downloads by Extension

A chaotic Downloads folder is a solved problem. Here's a macro that runs every evening and keeps it clean automatically.

Target Folder Structure

Before building the macro, we define the target organization. The Downloads folder gets these subfolders:

  • _archive/ - Files older than 7 days (safe holding area before deletion)
  • pdfs/ - All .pdf files
  • images/ - .jpg, .jpeg, .png, .gif, .webp, .svg
  • videos/ - .mp4, .mkv, .avi, .mov
  • archives/ - .zip, .rar, .7z, .tar, .gz
  • docs/ - .docx, .xlsx, .pptx, .txt, .csv

Macro vs Post-Script: When to Use Which

For file operations, we use Repio's post-script action type rather than GUI automation. File moving is a system operation - using PowerShell directly is faster, more reliable, and handles edge cases like duplicate filenames automatically.

The macro CSV is a single action row that calls a PowerShell script file. This is the right separation: Repio handles scheduling and triggering, PowerShell handles the actual file operations.

Rule of thumb: Use mouse/keyboard actions in Repio for interacting with application GUIs. Use post-script actions (PowerShell, Python, batch) for file system operations, API calls, and data processing.

The Sorting Script

The PowerShell script (saved as organize-downloads.ps1) handles all the sorting logic:

# organize-downloads.ps1
 = [Environment]::GetFolderPath("UserProfile") + "\Downloads"

# Create subfolders if they don't exist
 = @("_archive","pdfs","images","videos","archives","docs")
foreach ( in ) { New-Item -Force -ItemType Directory "$f" | Out-Null }

# Sort by extension
Get-ChildItem  -File | ForEach-Object {
   = extglob.Extension.ToLower()
   = switch () {
    ".pdf" { "\pdfs" }
    { ".jpg",".jpeg",".png",".gif",".webp" -contains extglob } { "\images" }
    { ".mp4",".mkv",".avi",".mov" -contains extglob } { "ideos" }
    { ".zip",".rar",".7z" -contains extglob } { "rchives" }
    { ".docx",".xlsx",".pptx",".txt",".csv" -contains extglob } { "\docs" }
    default {  }
  }
  if () { Move-Item extglob.FullName  -Force }
}

Task Scheduler Setup

The Repio macro CSV for the file organizer is a single line:

action_type,button,x,y,delay_ms,comment
script,,,,powershell -ExecutionPolicy Bypass -File C:\Scripts\organize-downloads.ps1,Sort downloads

To schedule it daily at 6pm, open Windows Task Scheduler: Create Basic Task, set trigger to Daily at 18:00, set action to Start a Program, program = path to repio.exe, arguments = --play organizer.csv. Enable the task and you are done.

Customization tips: Add an age filter to only move files older than 3 days (prevents moving files you just downloaded). Add duplicate detection by checking if the destination already has a file with the same name before moving.

Clean up your file system automatically.

Download Repio free and set up your scheduled file organizer today.

Download Repio Free