Estimated reading time at 200 wpm: 8 minutes
My Downloads folder has a reputation. It starts each day as a convenient holding pen for files I need briefly. By the end of the week, it becomes a digital landfill of installers, PDFs, screenshots, ZIP files, videos, and documents I meant to file but never did.
Whether or not you agree our Fat Disclaimer applies
Clicking through hundreds of files trying to remember what is safe to delete is tedious. Sorting by date or type helps a little, but still leaves me scrolling past things I do not want to see. But the problem is not specific to the Downloads folder. I have files all over the place that need weeding out.
I knew Windows File Explorer has a hidden search language. Operators like kind:, size:, and modified: can turn chaos into order in seconds. The problem was remembering the syntax and typing it out every single time.
First Attempt: Espanso
I started with Espanso, a text expander I already use for snippets and boilerplate text. My plan was simple: create shortcuts that would expand into search operators.
For example, typing :kind would become kind: and I would type the value afterwards. Or I could use :kinddoc to become kind:document directly.
Basically Espanso was a bad idea.
Creating Espanso triggers for every combination would mean hundreds of shortcuts. That is not practical. I needed a proper tool, not a text expander pretending to be one.
Second Attempt: AutoHotkey
I already had AutoHotkey installed, so I decided to write a small script. My goal was a graphical window where I could select search criteria from dropdowns, click a button, and have the search string inserted into File Explorer automatically.
The following is about the process. For those interested in the script, scroll down to get it. See how to use it. I’ll still use FolderSizes for more cumbersome tasks or granular tasks.
Version 1: Basic Builder
The first working script had three dropdowns for Kind, Size, and Date. It worked perfectly. Press Win+F, a window appears, select your options, click Build Search, and the search runs.
The ControlFocus Error
I hit one snag. The script tried to focus File Explorer’s search box using ControlFocus("Edit1", "A"). This failed with a “Target control not found” error.
The solution was simpler than I expected. Instead of hunting for the correct control name, I used SendInput("^e") — the native Windows shortcut for focusing the search box. A brief Sleep(50) pause, then SendInput(SearchString). Reliable across all versions of Windows.
Improving the Options
The initial dropdown options were generic: “large” for size, “last month” for date. I wanted them to be informative, showing exactly what would be inserted.
| Before | After |
|---|---|
| large | >100MB |
| huge | >500MB |
| last month | >1 month |
| (none) | >3 months |
I also added >5MB and >10MB after discovering rubbish large documents I had never read. The informative options helped me find and delete them.
Adding Exclusions
The next addition was the NOT operator. A fourth dropdown for Exclusions sits at the top of the window with “(None)” as the default. Options include:
NOT Installers(excludes.exe,.msi, etc.)NOT VideosNOT Screenshots(excludes files with “screenshot” in the name)NOT Pictures,NOT Documents,NOT Music,NOT Folders
If “(None)” is selected, nothing is added. The script still works perfectly.
The Final Script
Here is the complete AutoHotkey v2 script:
#Requires AutoHotkey v2.0
#SingleInstance Force
#HotIf WinActive("ahk_class CabinetWClass")
#f::
{
SearchGui := Gui("+AlwaysOnTop", "File Explorer Search Builder")
; Exclusions
SearchGui.Add("Text",, "Exclude:")
excludeDDL := SearchGui.Add("DropDownList", "vExclude",
["(None)",
"NOT Installers",
"NOT Videos",
"NOT Pictures",
"NOT Screenshots",
"NOT Documents",
"NOT Music",
"NOT Folders"])
excludeDDL.Choose(1)
; Kind (File Type)
SearchGui.Add("Text",, "File Type (kind):")
kindDDL := SearchGui.Add("DropDownList", "vKind",
["(Any type)",
"Pictures",
"Documents",
"Videos",
"Music",
"Programs/Installers",
"Folders"])
kindDDL.Choose(1)
; Size
SearchGui.Add("Text",, "Size:")
sizeDDL := SearchGui.Add("DropDownList", "vSize",
["(Any size)",
">5MB",
">10MB",
">100MB",
">500MB",
">1GB",
"<1MB"])
sizeDDL.Choose(1)
; Date Modified
SearchGui.Add("Text",, "Modified Date:")
dateDDL := SearchGui.Add("DropDownList", "vDate",
["(Any date)",
"today",
"this week",
">1 month",
">3 months",
">6 months",
">1 year",
">2 years"])
dateDDL.Choose(1)
; Buttons
buildBtn := SearchGui.Add("Button",, "Build Search")
cancelBtn := SearchGui.Add("Button", "x+m", "Cancel")
buildBtn.OnEvent("Click", (*) => BuildSearch(SearchGui))
cancelBtn.OnEvent("Click", (*) => SearchGui.Destroy())
SearchGui.Show()
}
BuildSearch(GuiObj)
{
Saved := GuiObj.Submit()
SearchString := ""
; Exclusion
if (Saved.Exclude != "(None)")
{
if (Saved.Exclude = "NOT Installers")
SearchString .= "NOT kind:=program "
else if (Saved.Exclude = "NOT Videos")
SearchString .= "NOT kind:=video "
else if (Saved.Exclude = "NOT Pictures")
SearchString .= "NOT kind:=picture "
else if (Saved.Exclude = "NOT Screenshots")
SearchString .= "NOT name:*screenshot* "
else if (Saved.Exclude = "NOT Documents")
SearchString .= "NOT kind:=document "
else if (Saved.Exclude = "NOT Music")
SearchString .= "NOT kind:=music "
else if (Saved.Exclude = "NOT Folders")
SearchString .= "NOT kind:=folder "
}
; Kind
if (Saved.Kind != "(Any type)")
{
if (Saved.Kind = "Pictures")
SearchString .= "kind:=picture "
else if (Saved.Kind = "Documents")
SearchString .= "kind:=document "
else if (Saved.Kind = "Videos")
SearchString .= "kind:=video "
else if (Saved.Kind = "Music")
SearchString .= "kind:=music "
else if (Saved.Kind = "Programs/Installers")
SearchString .= "kind:=program "
else if (Saved.Kind = "Folders")
SearchString .= "kind:=folder "
}
; Size
if (Saved.Size != "(Any size)")
SearchString .= "size:" Saved.Size " "
; Date
if (Saved.Date != "(Any date)")
SearchString .= "modified:" Saved.Date " "
; Send to File Explorer
SendInput("^e")
Sleep(50)
SendInput(SearchString)
GuiObj.Destroy()
}
#HotIf
How to Use It
- Install AutoHotkey v2 if you have not already
- Save the script as
FileExplorerSearch.ahk - Double-click to run it (the green H icon appears in the system tray)
- Press
Win+Fin any File Explorer window - Select your criteria from the dropdowns
- Click Build Search
The search runs automatically. No typing required.
Why This Works Better
| Problem | Espanso | AutoHotkey |
|---|---|---|
| Many combinations | Cumbersome (hundreds of shortcuts) | Simple (dropdowns handle everything) |
| Dropdown menus | Buggy on Windows (Alt key interference) | Works perfectly |
| Informative options | Not applicable | Shows exact syntax (>100MB, not “large”) |
| Exclusions | Difficult to implement | Native NOT operator support |
What I Learned
First, use the right tool for the job. Espanso is excellent for expanding snippets and correcting typos. It is not designed for building complex, multi-option search strings.
Second, AutoHotkey is more approachable than I expected. The v2 syntax is cleaner than the classic version. Within and hour of trial and error, plus some AI assistance, I built a tool that saves me time every day. I save drive space.
Third, informative options matter. Seeing >3 months instead of “last month” tells me exactly what I am searching for. I found documents I had not opened in over a year. I found screenshots taking up hundreds of megabytes. I found installers for software I uninstalled months ago.
The Result
My Downloads folder especially no longer fills me with dread. When it starts to get cluttered, I press Win+F, select a few options, and delete what I do not need. The whole process takes under a 10 minutes for a declutter session and I’m more certain about what I’m deleting.
The script works in any folder — Downloads, Documents, Desktop, even network drives. I have started using it to find large files across my entire system.
If you struggle with a cluttered Downloads folder, try the script. Modify the size and date options to match your needs. Add more exclusion types. Make it yours.
I’m off to declutter!











