I had a folder into which I had over 1 million files created by wimlib-imagex. I was unable to delete these files even after taking ownership of all files and folders.
I spent about an hour and a half trying to delete these with no success. I sat back a few minutes and came up with two ideas that I thought might work. The first is not very practical, but I will document it here just for completeness.
Option 1 (Not recommended): In case of desperation, you could do a full disk image backup, EXCLUDING the folder that you want gone. Then restore that same image. It's way too much work, but in desperation, that should work if your backup software allows exclusions.
Option 2 (Recommended): Let's say that the folder you want to get rid of is called C:\BadFolder. Do this to get rid of it:
Open a command prompt and create a temporary, empty folder. I created C:\EmptyFolder.
Run this robocopy command (substitute the appropriate folder names):
robocopy C:\EmptyFolder C:\BadFolder /mir
This tells robocopy to MIRROR or duplicate the empty folder to the bad folder, which includes deletion of any files and folders that are not present in C:\EmptyFolder. Since this folder contains nothing, it simply deletes everything in C:\BadFolder and it has the ability to delete those pesky files that could not be deleted in other conventional ways.
CAUTION: This does not move files to the recycle bin. They will be deleted permanently.
TIP: If you have many files like I did, minimize the command prompt while robocopy is running. It will run faster without having to scroll hundreds of thousands of file names on the screen.
I spent about an hour and a half trying to delete these with no success. I sat back a few minutes and came up with two ideas that I thought might work. The first is not very practical, but I will document it here just for completeness.
Option 1 (Not recommended): In case of desperation, you could do a full disk image backup, EXCLUDING the folder that you want gone. Then restore that same image. It's way too much work, but in desperation, that should work if your backup software allows exclusions.
Option 2 (Recommended): Let's say that the folder you want to get rid of is called C:\BadFolder. Do this to get rid of it:
Open a command prompt and create a temporary, empty folder. I created C:\EmptyFolder.
Run this robocopy command (substitute the appropriate folder names):
robocopy C:\EmptyFolder C:\BadFolder /mir
This tells robocopy to MIRROR or duplicate the empty folder to the bad folder, which includes deletion of any files and folders that are not present in C:\EmptyFolder. Since this folder contains nothing, it simply deletes everything in C:\BadFolder and it has the ability to delete those pesky files that could not be deleted in other conventional ways.
CAUTION: This does not move files to the recycle bin. They will be deleted permanently.
TIP: If you have many files like I did, minimize the command prompt while robocopy is running. It will run faster without having to scroll hundreds of thousands of file names on the screen.
My Computers
-
At a glance
Win11 Pro 25H2 (RTM+)Intel i7-14650HX32 GBNo GPU - Built-in Intel Graphics- OS
- Win11 Pro 25H2 (RTM+)
- Computer type
- PC/Desktop
- Manufacturer/Model
- Acemagic
- 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 25H2 (RTM+)Intel i7-1255U16 GBIntel Iris Xe Graphics- Operating System
- Win11 Pro 25H2 (RTM+)
- 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
- 2 TB 4 x 4 NVMe SSD
- PSU
- USB-C / Thunderbolt 4 Power / Charging
- 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







