Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

skilledtroll

macrumors newbie
Original poster
Nov 24, 2013
3
0
how do i make a folder that cant be deleted and the contents inside it cant either i just want to make a folder that cant de put in the trash or emptied from the trash and the contents inside the folder cant either and it doesnt have to be a folder it can be a zip too i tried encryption too but that u can just put in to the trash and empty it so yea
 

mfram

Contributor
Jan 23, 2010
1,307
343
San Diego, CA USA
If you change the directory so that you do not have write access, then you won't be able to delete it or any files inside it. But you won't be able to add files either. It appears that Finder will let you move such a directory to the trash, but you will have to enter your password first.
 

skilledtroll

macrumors newbie
Original poster
Nov 24, 2013
3
0
If you change the directory so that you do not have write access, then you won't be able to delete it or any files inside it. But you won't be able to add files either. It appears that Finder will let you move such a directory to the trash, but you will have to enter your password first.
well i need something that makes it completly locked like the systems folder or core services folder
 

old-wiz

macrumors G3
Mar 26, 2008
8,331
228
West Suburban Boston Ma
The systems folders aren't completely locked; you just need the right permissions.

Any folder created has an owner, and the owner can always change it. The contents are under the same rules.

You can make it difficult to delete a file/folder, but there's always someone owning the directory or the directory above it.

Similar questions get asked like "how can I prevent this file from being copied to an external device?" The answer is you can't - as long as a file can be read it can be copied.

Is this thread a serious question?
 

drew627

macrumors regular
Jun 26, 2013
199
22
Is this thread a serious question?

You must have been thrown off by the guy's name and his registration date. I read the post earlier but didn't reply because of that. plus he apparently knew of the core services folder and yet he didnt know that it can in fact be trashed (if he had tried)...
 

AdeFowler

macrumors 68020
Aug 27, 2004
2,317
361
England
how do i make a folder that cant be deleted and the contents inside it cant either i just want to make a folder that cant de put in the trash or emptied from the trash and the contents inside the folder cant either and it doesnt have to be a folder it can be a zip too i tried encryption too but that u can just put in to the trash and empty it so yea

You can lock a file from the get info panel, and you won’t be able to put it in the trash. You’ll be asked for your password before deleting anything in the folder. You have to unlock the folder before you can add anything to it.
 

boast

macrumors 65816
Nov 12, 2007
1,407
860
Phoenix, USA
best approach is create a new partition just for the folder. then set a script that remounts the partition and read only on boot.
 

SlCKB0Y

macrumors 68040
Feb 25, 2012
3,426
555
Sydney, Australia
You must have been thrown off by the guy's name and his registration date.

You haven't exactly been around here all that long either.

His question is 100% legitimate - on Linux what he is asking is achievable with "chattr +i" to set the file or directory as immutable. Once done not even su or root can write the file.

Unfortunately this is not available under OS X.
 

chown33

Moderator
Staff member
Aug 9, 2009
10,725
8,383
A sea of green
You haven't exactly been around here all that long either.

His question is 100% legitimate - on Linux what he is asking is achievable with "chattr +i" to set the file or directory as immutable. Once done not even su or root can write the file.

Unfortunately this is not available under OS X.

Something similar is:
Code:
sudo chflags schg /path/to/file
See the 'chflags' man page:
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/chflags.1.html

Be sure to read the info at the link to chflags(2) under SEE ALSO, which explains exactly what the flag (SF_IMMUTABLE) does, and how it can be cleared (single-user mode).

The related "uchg" flag is the well-known "Locked" checkbox in the Finder's Get Info window for a file or folder.


Note that if "schg" is set on a folder, then nothing can be added or renamed in that folder. Since the OP didn't say anything about those actions, I took his question to mean that he ONLY wanted to prevent deletion. Also, his later post "completly locked like the systems folder or core services folder" didn't help clarify, because neither of those folders are completely undeletable. And he didn't mention the Linux 'chattr +i' command, so again, not really clear exactly what was wanted.
 

pjny

macrumors 6502a
Feb 18, 2010
798
159
I accidentally delete an important folder once on my desktop. Is there a way to have folder undeletable but allow files to be dropped inside it?
 

KALLT

macrumors 603
Sep 23, 2008
5,360
3,378
I accidentally delete an important folder once on my desktop. Is there a way to have folder undeletable but allow files to be dropped inside it?

You can add an access-control list to the folder to stop you from deleting it. Only root can delete it, be aware of this.
Code:
chmod +a "everyone deny delete" <folder>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.