Saturday, July 4, 2020

#1 2020-05-11 10:26:08 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 10

Automate a hot folder for permission change

Hi there,

Is there a way to set up a watched folder which, whenever a folder or file is passed within it, it takes on the same permissions as that folder, as well as its enclosed items, eg "everyone; Read & Write"?

I am copying files across from a different domain (PC) to use in my job and storing them on a RAID system connected to the Mac. When i've finished with these files and folders and completed my task I file these in a structure on the RAID. These files and folders are taking the permissions with them from the PC domain which causes issues to a cloud backup system. This regularly back up but is failing every time as it does not have the correct access to these due to the permissions of these copied files not being the same as the enclosing RAID folder.

To rectify I have to do a global permissions change to the RAID - ensuring enclosed items is selected. And in future I have to ensure I alter the permissions of each folder and enclosed contents when I copy over from the PC domain. It's this process I'd like to automate.

Any help much appreciated.

Regards


Filed under: folder, watched, Permissions

Offline

 

#2 2020-05-11 10:56:00 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Automate a hot folder for permission change

Applescript:

on adding folder items to theFolder after receiving theNewItems
   repeat with anItem in theNewItems
       do shell script "chmod -R 777 " & quoted form of posix path of anItem with administrator privileges
   end repeat
end adding folder items to

You may drag and drop one or several item(s) on the hot folder.
A password will be asked once

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 11 mai 2020 18:55:28

Edited the mode from 755 to 777
Added the parameter -R to apply in the folder's hierarchy

Last edited by Yvan Koenig (2020-05-12 08:24:19 am)

Offline

 

#3 2020-05-12 02:25:20 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 10

Re: Automate a hot folder for permission change

Hi Yvan, thank you for this.

However, is there any modifications I need to do to this script as it doesn't seem to work?

I have admin privileges on the Mac and have assigned the script to the relevant folder via the folder actions set up.
When I copy across a folder from the PC domain and place in the folder I get the password prompt which I enter. When I check the permissions of the folder copied (and its contents) they have remained unchanged - the "everyone" user is either read only or no access and I have to manually change once more.

Could it be I don't have full admin privileges? But then I wouldn't be able to do it manually.

Any clues on what I'm doing wrong?

Many thanks for your help.

Offline

 

#4 2020-05-12 04:19:38 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Automate a hot folder for permission change

With the setting 755 you are supposed to get :
You : read/write
staff : read only
everyone : read only

If you get other settings it's that something failed but I have no idea of what is failing.

If you edit the script replacing 755 by 777 you are supposed to get:
You : read/write
staff : read/write
everyone : read/write

Once again, if you get other settings it's that something failed but I have no idea of what is failing.

I tested both versions on my system and both worked flawlessly.

I apologizes but I have no way to check if you attached the script correctly to the folder.

You may try to set - manually - the attributes of a folder to
You : write only
staff : write only
everyone : write only
and drag and drop it upon the supposed hot folder.
It the attributes aren't modified it's clear that something fail and the firstv explanation would be that you didn't apply correctly the attach process.

I will try to explain but I'm not sure that my poor English will be clear enough.
1-- store the script saved as xxx.scpt in the folder :   "Macintosh HD:Library:Scripts:Folder Action Scripts:"
2-- execute the application : "Macintosh HD:System:Library:CoreServices:Applications:Folder Actions Setup.app:"
You will get a window with a check box whose title means "Activate Folder Actions".
Check, it
In the left area you must add the supposed hot folder using the navigation dialog displayed by a click upon the 1st [+] button.
When it's done if the script doesn't appear in the right area you must add it after clicking upon the 2nd [+] button.
When the script is available in this right area you must check its own check box.

After that, if everything worked flawlessly, the script would be attached to the folder.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 12 mai 2020 12:00:34

Offline

 

#5 2020-05-12 04:47:41 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 10

Re: Automate a hot folder for permission change

Superb!

It was the 777 that I needed!

Thank you so much Yvan - this has saved me a load of pain with repetitive tasks that I would probably forget to do at some point and mess up the backup.

BTW, your English was perfect! wink

Excellent!

Offline

 

#6 2020-05-12 05:02:34 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 10

Re: Automate a hot folder for permission change

Hi Yvan,

Sorry - another question - although the script works now on the folders copied across any files within those folders remain unchanged.

Is there a way for the script to change the permission on the folder and all enclosed items?

Thanks in advance again.

Offline

 

#7 2020-05-12 08:25:49 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Automate a hot folder for permission change

I edited message #2.
Now the script apply to the folder and i's full hierarchy of contained items.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 12 mai 2020 16:25:43

Offline

 

#8 2020-05-12 08:47:24 am

TheBlackBinLiner
Member
Registered: 2019-12-05
Posts: 10

Re: Automate a hot folder for permission change

Outstanding! Works like a dream now.
Thank you very much!

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)