I may have referenced this in another post in the past but thought that I would just create a quick post just for this topic.
I do a lot of work with Windows images and on occasion I will interrupt a process working with these images. That can literally result in tens of thousands of files that simply won't allow me to delete them. In the past I had tyo take ownership of the files and take a number of additional steps before I could delete those files. But one day I had a sudden realization: Robocopy can delete those files because it has special system permissions allowing it to delete those files. So, here is an easy way to clean out a folder of "undeletable" files.
Create an empty folder.
Use robocopy to mirror the contents of that folder to the problem folder. It is literally that simple.
Here is an example using a folder called BadFiles that needs to be cleared.
I do a lot of work with Windows images and on occasion I will interrupt a process working with these images. That can literally result in tens of thousands of files that simply won't allow me to delete them. In the past I had tyo take ownership of the files and take a number of additional steps before I could delete those files. But one day I had a sudden realization: Robocopy can delete those files because it has special system permissions allowing it to delete those files. So, here is an easy way to clean out a folder of "undeletable" files.
Create an empty folder.
Use robocopy to mirror the contents of that folder to the problem folder. It is literally that simple.
Here is an example using a folder called BadFiles that needs to be cleared.
Batch:
md c:\EmptyFolder
robocopy c:\EmptyFolder c:\Badfiles /mir
rd C:\EmptyFolder
My Computers
-
At a glance
Win11 Pro 26H2 (Release Preview)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics- OS
- Win11 Pro 26H2 (Release Preview)
- Computer type
- PC/Desktop
- Manufacturer/Model
- Acemagic Matrix M5
- CPU
- Intel i7-14650HX
- Memory
- 32 GB
- Graphics Card(s)
- No GPU - Built-in Intel Graphics
- Sound Card
- Integrated
- Monitor(s) Displays
- Varies as machine will often be moved to locations with different monitors
- Screen Resolution
- Varies
- Hard Drives
- 1 x 1TB Gen 4 NVMe SSD
- PSU
- 120W Power Brick
- Keyboard
- Corsair K70 Max RGB Magnetic Keyboard
- Mouse
- Logitech MX Master 3
- Internet Speed
- 1Gb Up / 1 Gb Down
- Browser
- Edge
- Antivirus
- Windows Defender
-
At a glance
Win11 Pro 26H2 (Release Preview)Intel i7-1255U16 GBIntel Iris Xe Graphics- Operating System
- Win11 Pro 26H2 (Release Preview)
- Computer type
- Laptop
- Manufacturer/Model
- Lenovo ThinkBook 13x Gen 2
- CPU
- Intel i7-1255U
- Memory
- 16 GB
- Graphics card(s)
- Intel Iris Xe Graphics
- Sound Card
- Realtek® ALC3306-CG codec
- Monitor(s) Displays
- 13.3-inch IPS Display
- Screen Resolution
- WQXGA (2560 x 1600)
- Hard Drives
- 4 TB 4 x 4 NVMe SSD
- PSU
- USB-C / Thunderbolt 4 Power / Charging Using an Anker 160W Charger
- Keyboard
- Backlit, spill resistant keyboard
- Mouse
- Buttonless Glass Precision Touchpad
- Internet Speed
- 1Gb Up / 1Gb Down
- Browser
- Edge
- Antivirus
- Windows Defender
- Other Info
- WiFi 6e / Bluetooth 5.1 / Facial Recognition / Fingerprint Sensor / ToF (Time of Flight) Human Presence Sensor




