can an Applescript change file permissions?

Is it possible to create an Applescript to change file permissions? I’m not seeing anything about it in any Dictionaries so I just want to double check. I’m trying to make something to change all permissions to read & write with an easy drag & drop…

You’ll have to use ‘do shell script “chown …”’

Hi Joe,

you can do it with the Finder, this is a simple version which doesn’t affect contents of a folder


on open theFiles
	repeat with oneFile in theFiles
		tell application "Finder"
			tell oneFile
				set owner privileges to read write
				set group privileges to read write
				set everyones privileges to read write
			end tell
		end tell
	end repeat
end open

or with the shell, the password must be an admin password:

property pass_word : "¢¢¢¢"
on open theFiles
	repeat with oneFile in theFiles
		do shell script "sudo chmod -R ugo+rw " & quoted form of POSIX path of oneFile password pass_word with administrator privileges
	end repeat
end open

Note: if the script will be used in a standard user without admin status, also the parameter user name must be added

Ah thanks.

But when I use your script as a folder action, nothing seems to change. Then when I make an app out of it, a drag & drop gives me a stack overflow. Any ideas what I’m doing wrong?

Sorry, applets and droplets need at least an explicit or implicit run handler e.g.

on run
	display dialog "Please drag some files onto the application's icon"
end run

Oh of course. Duh, I should have noticed that. Thanks! :slight_smile:

Stefan;

I am forming a text file using:

NSCurrentApp's NSFileManager's defaultManager()'s createFileAtPath:theFile |contents|:theInitialTag attributes:(missing value)

For some reason, GetInfo shows the standard permissions, it it can’t be opened by the program that created it due to a lack of permission.

The same act of forming the new file results in the quarantine extended attribute being set. I can remove that with a script call to attr (with the -d parameter), but both these things shouldn’t really happen on ones own machine and account.

Any ideas?

Model: MacBook Pro (retina)
AppleScript: 2.9
Browser: Firefox 64.0
Operating System: macOS 10.14