Problem
I want to use Python script to replace MacOS finder folder icon with an image.
Steps
1. Install packages
pip3installpyobjc-core pyobjc-framework-Cocoa
2. Create a python script fileset-icon.py
with the following code.
importsys,Cocoafolder_path=sys.argv[1]print(f"Folder path:{folder_path}")image_path=sys.argv[2]print(f"Image path:{image_path}")result=Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(image_path),folder_path,0)ifresult:print("Succeed")else:print("Failed")
3. Run the script to change the icon.
python3 set-icon.py <folder path> <image path>
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse