How can I auto remove permissions from a file / document?

Hello….I'm using an app called Hazel. Hazel monitors a folder for me called "CrashReporter" (Mac HD / Library / Logs / CrashReporter) and if anything lands in the CrashReporter folder Hazel will send it to the trash. This works nicely when my Mac keeps sprouting up various reports. So the problem is when my Mac deposits a document called "CoreCapture" into the CrashReporter folder. Why? Because CoreCapture is permission limited or protected. In other words Hazel can't transfer it to the trash because of its limited permissions. I can manually change CoreCapture's permissions and send it to the trash, but the process happens several times a day and it gets tiresome manually unprotecting the file so I can trash it…….Here is my question: can KM run a macro that will change the permission of a file? As part of Hazel's workflow I think Hazel can run shell scripts or macros? ….If this is doable please explain it to me as if you were taking to a fence post. I use KM a lot but only its most basic features. And thanks much for any input….Mike

KM has an action that can do that:

image

However I have never used it, so you will need to experiment on your own or wait for someone else to help explain it.

What exactly are you doing when you say you "manually unprotect the file"? That would help me to know how to create an equivalent action in KM.

Sure...I select the file and choose get info. I unlock the lock (at the bottom of the GI window) and change the privileges to Reed and Write. Then I move the file to the trash.

Well, one (brute force) way is to write a KM macro that repeats your mouse clicks. But that requires some skills at using certain KM actions like Find Image. So I'll give you a better way...

A smarter way is to use the KM action or a shell command to replicate your mouse clicks. One way to determine which command is required to modify the file's permissions is to examine the file's permissions before and after you make the change using the GUI. I think you can do this by opening a Terminal window and typing "ls -l" in the folder where the file is located. This will show you exactly what changes are made to the file. (The description you gave me in your last post isn't really enough information.)

Once you determine the file's permissions before and after your change, it's possible to create a command that will do the same thing. Or maybe we can just assume the worst case and remove all restrictions from the file. That can probably be done like this:

chmod 777 /path/filename

That may not be the ONLY thing you have to do, but it should cover 95% of the possible situations.

Other commands that you might need in some cases are:

chflags nouchg /path/to/file
xattr -d com.apple.quarantine /path/to/file

So, yes lets assume the worst case scenario..."chmod777/path/filename" - what does "chmod777" represent? And are you talking inside the terminal or Using KM? thx for your time, Airy...

Change them for which entry? And do you have to authenticate to make the change?

chmod is the "change file modes" command. 777 is the "absolute mode" representation of "set the permissions to 'allow read, write, and execute' (7) for the owner (first number) and group (second number) of the file and also for 'everyone' (the third number).

Open up a Terminal window, type man chmod then hit Return to learn more.

You can do this in Terminal, in a KM "Shell Script" action, or (I believe) as part of your Hazel workflow. The trickiness comes if the file isn't "owned" by you -- you may have to authenticate.

BUT...

Why are you doing this? The CoreCapture directory is automatically recreated by the system and is generally empty -- you're creating unnecessary work rather than saving space. Put an exemption in your Hazel rule so that directory isn't deleted.

Better yet -- don't run this rule! Crash reports can be important in troubleshooting, yet you are throwing them away before you know if you might need them. If so many are being generated that they are becoming a problem then you've far more important issues to deal with -- like why are things crashing so often!

Since Nige is on the case now, you should now follow his very wise advice. But to answer your question, I was talking about using the Terminal app, but if that worked we can move the command inside a KM action. And why are you omitting the spaces I had around "777"? You can't do that; you have to copy exactly what I wrote.

Thank you Airy and Nige for the attempt…some of it was helpful. As to why I would delete CoreCapture: I don't think I could move you to the place where you would understand. Thanks again.