简体   繁体   中英

PermissionError: [Errno 1] for os.rename as quick action

This question represents the latest issue encountered when solving another problem. Let me explain the current issue first and leave the initial difficult at the end.

os.rename(old_path, new_path)

This Python command works when running the Python script in Automator (using the the run button on the top right).

/usr/local/bin/python3 "/Users/user/Library/Scripts/move.py"

However, when run as a quick action, it throws the error

The action “Run Shell Script” encountered an error: “Traceback (most recent call last):
File "/Users/user/Library/Scripts/move.py", line 6, in <module>
os.rename(folder_path, folder_nath)
PermissionError: [Errno 1] Operation not permitted:

All suggested solution tell me to grant various programmes full disk access. However, after having done so for Terminal, Finder, Automator and bash , I still see the error. I even changed the permissions for the folder to be renamed in the 'Get info' box. Nothing has helped.


This problems seems to be isomorphic with a problem I had earlier with another commend not working as a quick action:

os.system("""/bin/mv \"""" + old_path + """\" \"""" + new_path + """\"""")

This command works in PyCharm ; it works when I run the python code containing it in Automator (using the Run button in the top right).

/usr/local/bin/python3 "/Users/user/Library/Scripts/move.py"

However, it does not work when I run this workflow as a quick action triggered by a keyboard short-cut: the quick action clearly works as the little cog rotates, but the file remains unchanged.

I have solved this issue. When it comes to quick actions like this, you need to grant full disk-access permission to the application open when you use the quick action.

As I use this quick action when using, for example, TextEdit, I needed to give TextEdit full disk-access permission.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM