Undeletable nested folders in Trash - Terminal expert please??

Joined
Jan 20, 2012
Messages
5,195
Reaction score
554
Points
113
Location
North Carolina
Your Mac's Specs
Air M2 ('22) OS 15.3; M3 iMac ('23) OS 15.3; iPad Pro; iPhone 14
If you don't like the Terminal method and the uncertainty, why not try using a utility like Trash It!???

Free and good reviews…
https://www.macupdate.com/app/mac/8214/trash-it

As suggested, the terminal commands work well but follow the advice in the link just provided, i.e. 'cd' to .Trash, and then the 'rm' command can be used safely; by itself, only single files are deleted and not those w/ sub-directories or nested files which require the use of options/switches - simply enter 'man rm' to see the manual for the remove command.

Now, I've used Trash It! rarely (keep in mind that your trash bin is NOT for storage, so anything there should be disposable unless accidentally placed) - the app seems to easily handle the individual files, but not the ones w/ sub-directories - using the terminal w/ the appropriate options was needed for me w/ some stubborn items. Finally, keep in mind that when in the terminal, using 'rm' is permanent, i.e. there is NO trash bin. Dave :)
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
by itself, only single files are deleted and not those w/ sub-directories or nested files which require the use of options/switches - simply enter 'man rm' to see the manual for the remove command.

Actually, my command is recursive... see the -r switch?
Assuming you cd to the dir first it wont cause any havoc, just delete ALL files/dirs in the Trash.
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
see Cradom's post # 8 above

Okay, thanks for that. So is the ~ for drive name, which in this case is Work ?

So:
cd ~/.Trash
and then
rm -rf *.*

Becomes:

cd Work/.Trash
and then
rm -rf *.*

Need to be sure...sorry.

Kryten
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
No. The ~ means your Home folder. So ~/.Trash means the .Trash folder in your Home folder.
There is no .Trash folder at the root of the drive (actually, there is but that's not where your trash is... and it's name is .Trashes).
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
No. The ~ means your Home folder. So ~/.Trash means the .Trash folder in your Home folder.
There is no .Trash folder at the root of the drive (actually, there is but that's not where your trash is... and it's name is .Trashes).

Thank you very much Cradom. I'll be trying this when I get back in the office at the weekend.

Sincere thanks to all who replied. I'll post the results back here when I'm done.

Thanks to all again.

Kryten
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Absolutely correct! Easier to
cd ~/.Trash
and then
rm -rf *.*
That way you only delete what's in the Trash.

Well, I'm sorry Cradom this hasn't worked. All nested folders are still sitting in the trash..?

Kryten
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Ok, do this:
cd ~/.Trash
sudo rm -rf *.*
It will ask for a password. Input your admin password. You wont see it but it's taking it (that's a security feature).

If this doesn't work the devil has possessed your computer :p
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Ok, do this:
cd ~/.Trash
sudo rm -rf *.*
It will ask for a password. Input your admin password. You wont see it but it's taking it (that's a security feature).

If this doesn't work the devil has possessed your computer :p

Nope, still sittin' there. Entered Admin password, hit return, nothing...!
The devil or perhaps the Matrix has me. Thanks for you help, much appreciated.
K.
 
Joined
Oct 16, 2010
Messages
18,177
Reaction score
1,921
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 don't know if the wrong permissions prevent things from happening, but have you tried the old make a file or folder with the same name as the one that won't delete, and let the Finder Replace it if it will when moved to the same Trash.

I can't recall if a file can replace a folder of if it's the other way 'round. But just maybe… ;)
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Yes, thank you pm-r. I just tried that and then sent to Trash and there they sat, identical named folders and the newly created folder deleted fine, but the other still sits there. Not sure if this is relevant, but as I click down through the folders the final nested folder with the weird name and symbols, when clicked on the Finder shows Calculating size (greyed out) but never actually produces a result, so not sure what's happening there.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Try this:
cd down to the last folder in the Trash. Ex: cd ./Trash/folder/folder etc. When you get to the last folder type:
ls -la (those are small L's)
Copy/paste here what you get for the file.
 
Joined
Oct 16, 2010
Messages
18,177
Reaction score
1,921
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
Hey I know, Kryten can post his address and enable Remote Desktop access and we can all invade his Mac and get rid of the pesky stubborn stuff fro him!! ;) :D
 
Joined
Oct 16, 2010
Messages
18,177
Reaction score
1,921
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
All jokes aside and with even Terminal being stubborn to empty the Trash, how's this for a suggestion?

Download and use Find Any File if you don't have it already:
Thomas Tempelmann - Find Any File

Use the Finder to copy the stubborn file/folder name, open FAF and paste in the copied name, hold the option button and click Find, it will ask for user password to get root permission.

When found and displayed in the found window, select it and right-click to use the Delete Immediately option.

It just might work… ;)
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Hey I know, Kryten can post his address and enable Remote Desktop access and we can all invade his Mac and get rid of the pesky stubborn stuff fro him!! ;) :D

Well noble gents, it may come to that. Here's the path:

cd ~/.Trash/Recovered movies/Recovered Files/Scan/Scan2/ ... and the weird titled folder sits in Scan2

Terminal says this: mac:.Trash HowardFillingham$ /Recovered movies
-bash: /Recovered: No such file or directory

So should I delete spaces?
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
All jokes aside and with even Terminal being stubborn to empty the Trash, how's this for a suggestion?

Download and use Find Any File if you don't have it already:
Thomas Tempelmann - Find Any File

Use the Finder to copy the stubborn file/folder name, open FAF and paste in the copied name, hold the option button and click Find, it will ask for user password to get root permission.

When found and displayed in the found window, select it and right-click to use the Delete Immediately option.

It just might work… ;)

Thank you pm-r. Well I get an error -5000 message....? But it does show the invisible 501 folder within the Trash that all nested folders sit.
 
Last edited:
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Can I paste a screenshot here? The final folder has a really long 'meaningless' title.
 

Slydude

Well-known member
Staff member
Moderator
Joined
Nov 15, 2009
Messages
17,936
Reaction score
1,359
Points
113
Location
North Louisiana, USA
Your Mac's Specs
M1 MacMini 16 GB - Sequoia, iPhone 14 Pro Max, 2015 iMac 16 GB Monterey
Guys I am wondering if the folders in the trash contained one or more locked files. I'm not sure if that affects the Terminal commands or not.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Shouldn't affect a sudo'ed rm. However worth a shot. Do a Get Info on all folders and make sure they're all unlocked.
Kryten do this: type cd, a space, and then drag the next to last folder from Finder to Terminal.
This will fill in the path with the spaces escaped already so the ls -le command will work.
Note I changed it to e from a. Checking ACL's here which could be a problem.
Fixing Mac OSX File Permissions and ACLs From the Command Line › Backdrift Backdrift

Edit: will be unavailable for a few hours. Thinking about upping to Yosemite again. Don't want to be stuck in the dark ages, even at my age.
 
Joined
Oct 16, 2010
Messages
18,177
Reaction score
1,921
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
With all the attacks and most failing, I'd sure try doing some shutdowns and startups, and maybe an OS purge might finally remove something. Restarts are not as thorough.
 
OP
Kryten
Joined
Mar 20, 2006
Messages
176
Reaction score
10
Points
18
Location
England
Your Mac's Specs
3.8 GHz 8-Core Intel Core i7 AMD Radeon Pro 5500 XT 8 GB / 80 GB 2133 MHz DDR4
Shouldn't affect a sudo'ed rm. However worth a shot. Do a Get Info on all folders and make sure they're all unlocked.
Kryten do this: type cd, a space, and then drag the next to last folder from Finder to Terminal.
This will fill in the path with the spaces escaped already so the ls -le command will work.
Note I changed it to e from a. Checking ACL's here which could be a problem.
Fixing Mac OSX File Permissions and ACLs From the Command Line › Backdrift Backdrift

Edit: will be unavailable for a few hours. Thinking about upping to Yosemite again. Don't want to be stuck in the dark ages, even at my age.

I tried the drag thing and got this:
mac:.Trash HowardFillingham$ cd /Volumes/Work/.Trashes/501/Recovered\ movies/Recovered\ Files/Scan/Scan2
mac:Scan2

Then typed: ls -le ( and got ):
total 0
drwxrwxrwx@ 3 root staff 102 15 Jan 19:38 :v?%9Esv?%[%F1%AD??%FA<M?]??%E3R%F4t?
 

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