Why Command Line Deletion Beats Clicking Through Folders
Every editing session leaves residue. Proxy media, render intermediates, exported drafts, scratch audio, thumbnail caches, and a dozen versions of a file you will never open again. Windows Explorer handles a handful of deletions fine. Point it at a folder tree with several hundred thousand small files and it becomes a liability: progress bars freeze, the "Calculating..." dialog lingers, and one locked file can abort an operation halfway through, leaving you unsure what was actually removed.
The command line solves that in three ways. It gives you filters, so you can delete every temporary file in a tree, or everything older than thirty days, without sorting anything by hand. It is repeatable, so a command you type once becomes a batch file or a scheduled task. And it is transparent, so you can log exactly what was removed and when.
The trade-off is real: there is no undo, and a single mistyped character can wipe a directory you needed. That risk is manageable only if deletion is treated as a procedure rather than a casual keystroke. The rest of this guide covers the commands, the switches, the failure modes, and the guardrails that keep speed from turning into a data-loss story.
Before You Delete: Inventory, Verify, Plan
Confirm where you actually are
cd with no arguments prints the current directory in Command Prompt. echo %CD% does the same inside a script. Verify the drive letter explicitly, because mapped network drives and external volumes shift when hardware is plugged in, and a letter that pointed at a scratch drive yesterday may point at an archive today.
List before you remove
The single most useful habit is running the same wildcard through dir first:
dir /s /b "D:\Projects\*proxies*" > C:\logs\proxy_list.txt
/s recurses, /b prints bare paths, and redirecting to a file gives you both a preview and a permanent record to compare against afterwards. To count matches without generating a huge list, pipe through find:
dir /s /b "D:\renders\*.mov" | find /c /v ""
Know your attributes and permissions
Files that are read-only, hidden, or system-tagged need extra switches. dir /a reveals them; attrib -r -h -s "path\file" clears the flags. Paths beyond the classic 260-character limit can fail in older commands, which is one reason tools like robocopy and PowerShell handle large media trees more gracefully.
Choose recoverable or permanent
del and rd bypass the Recycle Bin. If you want a safety net, either move files into a staging folder on the same volume first (an instant metadata operation, since nothing is copied), or use the PowerShell method later in this guide that sends items to the Recycle Bin instead.
The Core Deletion Commands and What Each One Really Does
del handles files, not folders
The syntax is del [drive:][path]filename [/P] [/F] [/S] [/Q] [/A[[:]attributes]]. Point del at a directory name and it asks whether you want to delete all files inside it, then removes those files while leaving subfolders and the folder itself in place.
/Pprompts before each file. Slow, but excellent for a first pass on a folder you do not fully trust./Fforces deletion of read-only files./Srecurses into subdirectories./Qsuppresses the confirmation prompt, but only in combination with/S./Afilters by attribute, for example/A:Hfor hidden files only.
rmdir (or rd) handles directories
rd without switches removes an empty folder and nothing else, which makes it inherently safe. Add /s and it removes the folder plus everything beneath it:
rd /s /q "D:\cache\render_temp"
/q turns off the confirmation prompt, so /s /q is the fast, final, unforgiving version of the command. Two quirks matter in practice: you cannot delete the folder you are currently standing in, and long operations often return an error code even when most files were successfully removed.
Wildcards reward precision
An asterisk matches any run of characters, a question mark matches exactly one. del /s /q "D:\shots\*.png" is a clean, targeted command.
The traps are subtle. A space before the dot, as in del * .txt, makes the asterisk match everything, and you end up deleting the entire contents of the folder. A trailing backslash inside quotes, as in rd /s /q "C:\Media\", can confuse the parser badly enough that the wrong directory is targeted. Both mistakes are common, and both are avoidable with a preview run.
A Safe Step-by-Step Deletion Workflow
- Close the applications that own the files. Editors, compositors, and background sync clients hold locks that cause partial deletions and confusing error messages.
- Preview with
dir, using the exact wildcard you plan to delete with. - Save the preview to a log file with a redirect.
- Delete without
/qon the first pass so you see the confirmation prompt and any errors. - Verify by running the same
dircommand again and comparing counts. - Only after two clean manual runs, wrap the command in a script or scheduled task.
A staging pattern is worth adopting for anything ambiguous: move candidates into a single _to_delete folder on the same drive with move, wait a week, then purge that folder with rd /s /q. Same-volume moves are metadata operations, so they are nearly instant even for terabytes, and the delay buys a recovery window that costs nothing.
Cleaning Video Project Caches, Renders, and Scratch Files
Editor and compositor caches
Media caches are the safest large win. Typical locations on Windows include cache folders under the Adobe common application data directory and Resolve cache folders under ProgramData, and every application lets you confirm or change the path in its preferences. Do not assume, verify.
For caches, empty the folder rather than deleting it, because some applications expect the directory to exist:
del /s /q "%APPDATA%\Adobe\Common\Media Cache Files\*"
Render and proxy folders
Project-based proxy folders rarely follow one naming convention, so combine wildcards with a directory loop:
for /d %D in ("D:\Projects\*") do @del /s /q "%D\Proxies\*.mxf"
Inside a batch file, use %%D instead of %D. Preview the same loop with dir before running it for real.
Frame sequences
Generated frame sequences are usually the single largest source of clutter. Four hundred PNG files for a six-second shot, multiplied across hundreds of shots, produces millions of small files that make Explorer crawl. Delete them by pattern, and expect shell deletion to be slow; the mirror technique in the next section is far faster.
System temp and developer folders
%TEMP% and C:\Windows\Temp accumulate installer payloads, log files, and crash dumps. Files in use will refuse to be deleted, and that is fine, they will go next time. If you prefer a guided approach, cleanmgr and Storage Sense handle system temp safely with far less typing and no risk of a mistyped path.
Automating Cleanup with Batch Files and Task Scheduler
A cleanup script only needs to be written once:
@echo off
setlocal
set TARGET=%~1
if "%TARGET%"=="" (echo Usage: cleanup.cmd "D:\cache" & exit /b 1)
if not exist "%TARGET%" (echo Path not found & exit /b 1)
echo Target: %TARGET%
dir /s /b "%TARGET%" | find /c /v ""
pause
del /s /q "%TARGET%\*"
for /d %%D in ("%TARGET%\*") do rd /s /q "%%D"
echo Cleanup complete.
Requiring the path as an argument prevents the script from ever running against a hardcoded folder by accident. The pause before deletion is not decoration; it is the last chance to cancel.
The mirror trick for very large trees
Deleting hundreds of thousands of files with del /s can take minutes and generate enormous filesystem churn. A faster alternative is to create one empty folder and mirror it over the target:
mkdir C:\empty
robocopy C:\empty "D:\huge_cache" /MIR /MT:32 /NFL /NDL /NJH /NJS /NP
Multi-threading makes this dramatically faster on large trees. Run it once with /L added first, which lists what would be deleted without touching anything. Once the destination is mirrored and empty, remove the folder itself with rd /s /q. Treat /MIR with the same caution as rm -rf: it deletes everything in the destination that is not present in the source.
Scheduling
schtasks or the Task Scheduler interface can run the script nightly, and appending output to a dated log file gives you an audit trail showing what each run removed.
PowerShell, macOS, and Linux: The Same Job, Different Dialects
PowerShell is worth learning for one feature alone: -WhatIf. Every destructive cmdlet supports it, and it prints what would happen without doing it.
Get-ChildItem "D:\renders" -Recurse -Filter *.tmp |
Where-Object LastWriteTime -lt (Get-Date).AddDays(-30) |
Remove-Item -Force -WhatIf
Remove -WhatIf once the output looks right. Remove-Item -LiteralPath "D:\cache" -Recurse -Force is the direct equivalent of rd /s /q, and -LiteralPath avoids wildcard surprises in folder names containing brackets.
If you want deletions to be recoverable, the .NET file system class can send them to the Recycle Bin instead:
Add-Type -AssemblyName Microsoft.VisualBasic
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory(
"D:\cache", 'OnlyErrorDialogs', 'SendToRecycleBin')
On macOS and Linux, rm -rf is the equivalent of rd /s /q, and find covers age-based filtering:
find /Volumes/Media/renders -type f -name "*.tmp" -mtime +30 -print
Run it with -print first, then swap in -delete. For recoverable deletion, install a trash utility; plain rm is permanent. rsync -a --delete empty/ target/ mirrors the robocopy trick for emptying huge trees efficiently.
Common Mistakes That Cause Data Loss
Assuming deletion is reversible. Command line removal skips the Recycle Bin, and there is no prompt once /q is in the command.
Trailing backslashes inside quotes. Always write "C:\Media", never "C:\Media\".
Typos that still resolve. D:\Projects and D:\Project may both exist. The preview run catches this; nothing else does.
Spaces inside wildcards. del * .txt and similar patterns match everything and delete far more than intended.
Standing inside the target. Deleting the current working directory produces partial results and error messages that mask real failures.
Elevated shells. Running as administrator removes the operating system's own guardrails and lets you delete files that normally resist, including application databases stored under ProgramData.
Junctions, symlinks, and mounted volumes. Links can point outside the tree you think you are cleaning. Modern Windows removes the link rather than the contents behind it, but behavior varies across tools and network paths, so exclude links explicitly when a tree contains them.
Forgetting that scripts inherit their environment. A scheduled task runs with a different working directory and different variables than your interactive shell, which is why scripts should always use absolute paths.
Recovery Options When You Delete the Wrong Thing
Stop writing to the affected drive immediately. Every new write reduces the chance of recovery.
Check the Recycle Bin anyway, in case some items were deleted through Explorer. Then look at shadow copies and File History: right-click the parent folder, open Properties, and check the Previous Versions tab. vssadmin list shadows shows what exists on the volume.
If the folder was synced to a cloud drive, version history and the cloud trash are usually the fastest fix, often with weeks of retention. For code and project files, version control saves the day: git status will show deletions, and git restore brings them back.
Beyond that, file recovery utilities can rebuild deleted files on traditional hard drives if little has been written since. Solid-state drives with TRIM enabled are far less forgiving. In practice, the reliable answer is a backup that was never in the deletion path, which is why cleanup scripts should only ever target folders that are either reproducible or already archived elsewhere.
Frequently Asked Questions About Command Line Deletion
Does del send files to the Recycle Bin?
No. Deletions from Command Prompt are permanent. If recoverability matters, use the PowerShell recycle bin method or a staging folder instead.
What is the fastest way to delete a huge number of small files?
The robocopy mirror technique, or rsync --delete on macOS and Linux. Plain del /s works but is far slower on trees with hundreds of thousands of entries, because each file is handled individually.
How do I delete only files older than a certain age?
forfiles /p "D:\renders" /s /m *.tmp /d -30 /c "cmd /c del @path" does it in one line. Preview it by replacing the delete command with echo so you see the matching paths first.
How do I target the same file type in many subfolders at once?
del /s /q "D:\path\*.tmp" handles it. If the parent path itself varies, combine a for /d loop with del /s /q and preview the loop with dir before running it.
Why does del report that it could not find a file?
The most common causes are an incorrect path, hidden or system attributes that require the /A switch, or a file name containing characters your wildcard did not match. Redirecting dir output to a log file usually reveals the difference quickly.
Can I delete the folder I am currently in?
No, and commands that try will fail with a "being used by another process" message. Move up one level first with cd ...
Is it safe to delete everything in the temp folder?
Mostly, yes. Files in use refuse to be removed, which is expected behavior and not an error worth chasing. Avoid manually deleting component store and system-managed caches such as the WinSxS directory; use the built-in disk cleanup tooling for those.
How do I avoid deleting something I need?
Preview with directory listings, log the output, delete in two phases using a staging folder, and keep anything irreplaceable in a backup the script cannot reach. Fast deletion is only useful when it never touches the wrong folder.



