当您没有读取权限时使用 Applescript 更改文件权限
有时,我公司的员工会得到一个文件,但由于某种原因,他们没有读取或写入权限。一个示例是从客户端 FTP 服务器下载文件。
我希望创建一些非常简单的东西,比如 applescript Droplet,它将更改放置在其上的文件的权限:
on open filelist
repeat with i in filelist
do shell script "chmod -R +wr " & quoted form of POSIX path of i with administrator privileges
end repeat
end open
问题是,由于用户没有读取权限,droplet 在 on 处立即失败打开 filelist
行。
删除 on open
块之间的所有内容:
on open filelist
end open
仍然会导致脚本失败。我所说的失败是指它会产生文件权限错误。
提前致谢。
Occasionally employees at my company will get a hold of a file that for some reason, they do not have read or write permission to. An example is downloading a file from a client FTP server.
I'm looking to create something very simple, like an applescript droplet, that will change the permissions for the files dropped on it:
on open filelist
repeat with i in filelist
do shell script "chmod -R +wr " & quoted form of POSIX path of i with administrator privileges
end repeat
end open
The problem is that since the user does not have read permissions, the droplet fails instantly at the on open filelist
line.
Removing everything between the on open
block:
on open filelist
end open
still results in the script failing. By failing, I mean it produces a file permission error.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题可能是您正在尝试使用用户无法读取的文件 - 这将导致 Droplet 无法工作,因为它取决于能否读取!
您将需要使用文件选择器编写正确的应用程序。这里的问题是您可以选择多个文件,但只能选择文件或文件夹。
无论如何,我过去写过类似的东西,所以请随意使用:
The problem could be that you are trying to work with files your user can not read - this will result in the Droplet not working, because it depends on being able to read!
You will need to write a proper application using a file chooser. The problem here is that you can choose multiple files, but only either files or folders.
Anyway, I´ve written something similar in the past, so feel free to use this: