How to force delete a stubborn file?

Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
I interrupted a process by a specific program and it left me with a file I can't delete. MacOS (Monterey 21G115) keeps telling me the file is in use. I've tried the following with no success:
1) Option-File -Delete Immediately
2) Terminal "RM " and drag file into window (I get "resource busy")
3) several other tricks that are supposed to turn "trash" into "secure trash" but I couldn't even get that to work

Way back in the past I had a script/macro (no clue where I got it that never failed to delete a file (and it bypassed the trash so there was risk involved) but it was lost when I upgraded my iMac a couple of years ago.

I haven't tried the obvious...a reboot...because every time I do something else goes wrong.

Any ideas?

Thanks!!
 
Joined
Oct 16, 2010
Messages
18,146
Reaction score
1,899
Points
113
Location
Brentwood Bay, BC, Canada
Your Mac's Specs
2020 27" i9 5K nano iMac, 1TB(partitioned) SSD, GB, macOS 15.3.1 Sequoia
I haven't tried the obvious...a reboot...because every time I do something else goes wrong.

I would have thought that was about one of the first things you would have tried, but you might want to do a Shutdown instead, wait 30 or 40 seconds, then boot up and try deleting the file, and if that doesn't work, Shutdown again but then when you boot up again, do so using safe boot mode and see if you cannot trash the file.
To get back to your normal use, just do a normal Restart.

Oh right, if it's still being obstinate, make sure it isn't locked or shared somehow using Get Info on the file and see what the option checkboxes say.

Good luck,



- Patrick
=======
 
Last edited:
Joined
Feb 1, 2011
Messages
4,902
Reaction score
2,902
Points
113
Location
Sacramento, California
Try this:

Create a new file or folder in a different folder or disk from the item you want to throw away. Give the new item the same exact name as the item you are trying to delete, and then move or copy it into the folder where the recalcitrant item is located. When the Finder asks you if you want to replace it, click Yes or Replace, and then throw the moved item away.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,030
Reaction score
2,435
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
Try this:

Create a new file or folder in a different folder or disk from the item you want to throw away. Give the new item the same exact name as the item you are trying to delete, and then move or copy it into the folder where the recalcitrant item is located. When the Finder asks you if you want to replace it, click Yes or Replace, and then throw the moved item away.
If the destination file is truly locked, this wouldn't work.

In this case, you should absolutely reboot the machine which will release all held locks and then delete just the file(s) that you want to get rid of and continue..
 
Joined
Jan 1, 2009
Messages
16,374
Reaction score
4,728
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
I haven't tried the obvious...a reboot...because every time I do something else goes wrong.
Do we need to explore this statement? Reboots should not make things go wrong. If they are, there is something more serious going on than just a file that can't be deleted.
 
Joined
Oct 16, 2010
Messages
18,146
Reaction score
1,899
Points
113
Location
Brentwood Bay, BC, Canada
Your Mac's Specs
2020 27" i9 5K nano iMac, 1TB(partitioned) SSD, GB, macOS 15.3.1 Sequoia
Reboots should not make things go wrong.

Man, if that statement was true there would surely be a lot of Mac users with some serious troubles.

Thanks for posting Jake, I was just about to reply to the OP's statement.



- Patrick
=======
 
OP
M
Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
To address several comments:

Trust me, reboots are my last resort. I usually have to do 2-3 before everything runs normally, and each one takes up to 15 minutes to complete (there goes my evening). That should not be the case but it is.

I can't copy files with the same name over it (That's how I discovered the issue). The info panel shows it as not locked, read/write privileges are normal. Not shared.

Here's an odd one though. I can rename it, I can move it, but I can't delete it.

FYIU, the file is on a NAS (should have mentioned that up front)
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
16,030
Reaction score
2,435
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
A reboot should be pretty quick if you aren't loading a lot of stuff on load and it should absolutely not cause issues as the system boots up, but let's leave that aside.

If the file is residing on a NAS, then just login to the NAS directly and delete the file.

Most NAS' use Linux as the OS and if you can SSH into it, do so and then use "sudo" to remove the file.
 
Joined
Jan 1, 2009
Messages
16,374
Reaction score
4,728
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Trust me, reboots are my last resort. I usually have to do 2-3 before everything runs normally, and each one takes up to 15 minutes to complete (there goes my evening). That should not be the case but it is.
Once you get past the recalcitrant file, I strongly suggest you work on that issue. Reboots should be quick, and should not take 2-3 of them to get things going properly. If that is really happening, you have very serious problems with that Mac.
 

Rod


Joined
Jun 12, 2011
Messages
10,414
Reaction score
2,479
Points
113
Location
Melbourne, Australia and Ubud, Bali, Indonesia
Your Mac's Specs
2021 M1 MacBook Pro 14" macOS 14.5 Mid 2010MacBook 13" iPhone 13 Pro max, iPad 6, Apple Watch SE.
Do you have "Reopen windows when logging back in" ticked? I would suggest you try unticking that. 15mins is ridiculously long for a Restart.
Maybe we can suggest something helpful but we need to know; what device (eg 2017 12" MacBook pro) and the Operating System at the very least.
It would also be good to know how much free storage is left on the internal drive because little or no storage can really slow things down.
 
OP
M
Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
Do you have "Reopen windows when logging back in" ticked? I would suggest you try unticking that. 15mins is ridiculously long for a Restart.
Maybe we can suggest something helpful but we need to know; what device (eg 2017 12" MacBook pro) and the Operating System at the very least.
It would also be good to know how much free storage is left on the internal drive because little or no storage can really slow things down.
2019 iMac, Monterey. I have over a TB free on my 2TB internal HD
 
OP
M
Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
Do you have "Reopen windows when logging back in" ticked? I would suggest you try unticking that. 15mins is ridiculously long for a Restart.
Maybe we can suggest something helpful but we need to know; what device (eg 2017 12" MacBook pro) and the Operating System at the very least.
It would also be good to know how much free storage is left on the internal drive because little or no storage can really slow things down.
Typically I close everything gracefully rather than shutdown with apps open.
 
Joined
Jan 1, 2009
Messages
16,374
Reaction score
4,728
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
OK, here are a couple of suggestions:

1. Get Etrecheck. Run it to see what is slowing down your system and to get a report on what is loading at boot time.
2. Open system preferences, Users & Groups, click on the "Login Items" for your account and see what is loading when you log in.

Once we know what is going on at boot, we can tackle the issues better.

One question, do you have a lot of peripherals attached to your Mac? Sometimes peripherals can slow a boot sequence as they have to be registered in the system. I know you mentioned the NAS where you are having the file name issue. Anything else?
 
OP
M
Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
I have 2xNAS with a combined 88TB of storage (Movie/TV server). Just opening a finder window sometimes can take 2-3 minutes, I suspect the NAS, but also think it shouldn't. I also have several USB drives (I use the NAS as my primary usage device and the USBs are connected to back them up). Other than that nothing crazy. Apple keyboard, trackpad and mouse. As for login items, I have 6 programs, all of which I use regularly.
 
Joined
Feb 1, 2011
Messages
4,902
Reaction score
2,902
Points
113
Location
Sacramento, California
...Just opening a finder window sometimes can take 2-3 minutes...

A severe slowdown such as you describe is usually either attributable to stay-resident software that is running amok (often anti-virus software, such as Sophos, but I've seen it caused by Little Snitch, or Dropbox, and a couple of others), or it is due to a failing hard drive.

To troubleshoot the problem I'd start by downloading the free demo of DriveDX and running it:

DriveDX - free demo
https://binaryfruit.com/drivedx

Any time it shows any drive errors in yellow or red, it is correlated with a drive that's likely severely on the decline.

If your drive comes up as healthy, then you need to track down the software that is causing the slowdown. See:

Macintosh Slowdown Solutions
http://www.macattorney.com/sd.html
 
Joined
Jan 1, 2009
Messages
16,374
Reaction score
4,728
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
I have 2xNAS with a combined 88TB of storage (Movie/TV server).
88TB! Wow, that is an amazing amount of storage.

Try removing those NAS devices from your login items and boot without them mounting. And then try ejecting them before shutting down. I have no idea what Finder does on startup, but if it's trying to get an inventory of 88TB of files, that could be the drag on both ends.

If, on the other hand, you meant 8TB and not 88TB, it probably isn't the trigger.
 

IWT


Joined
Jan 23, 2009
Messages
10,698
Reaction score
2,599
Points
113
Location
Born Scotland. Worked all over UK. Live in Wales
Your Mac's Specs
M2 Max Studio Extra, 32GB memory, 4TB, Sequoia 15.4.1 Apple 5K Retina Studio Monitor
Joined
Jan 1, 2009
Messages
16,374
Reaction score
4,728
Points
113
Location
Winchester, VA
Your Mac's Specs
MBP 16" 2023 (M3 Pro), iPhone 16 Pro, plus ATVs, AWatch, MacMinis (multiple)
Just for information purposes:

Yes, there is an 88TB "drive" - actually a server - it costs close to £30,000 -

But I suspect that the OP meant 8TB.

Ian
I didn't doubt that someone could have 88TB of data, it is just that it is an incredible amount of storage for a home user for movies/TV.
 
Joined
Oct 16, 2010
Messages
18,146
Reaction score
1,899
Points
113
Location
Brentwood Bay, BC, Canada
Your Mac's Specs
2020 27" i9 5K nano iMac, 1TB(partitioned) SSD, GB, macOS 15.3.1 Sequoia
Yes, there is an 88TB "drive" - actually a server - it costs close to £30,000 -

Wow and good grief... That should keep a movie buff busy watching movies for about a hundred lifetimes if it was full of movies... :rolleyes:




- Patrick
=======
 
OP
M
Joined
Feb 9, 2022
Messages
64
Reaction score
6
Points
8
Nope, 88TB was correct. I'm a hoarder :)

2x Synology DS420. One has 4x 12TB drives and the other has 4x10TB drives. I don't raid them (I'm cheap) but back them up regularly to USB drives.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top