Use a photo as a folder icon?

I know how to make a photo the icon for a folder, just wondering if anyone has found a faster way to apply the photo to the folder? It's a lot of steps as it is now. Anyway to drag and drop? Any 3rd party app that does this? Like my left folder shown here.

Posted on Jun 19, 2020 6:30 PM

Reply
Question marked as Top-ranking reply

Posted on Jun 20, 2020 10:01 AM

Here is an AppleScript using Objective-C to select the image, and then select the folder target. It places the image on the folder. There are three ways to revert the folder icon:

  1. Run the script again with a different picture (ideally a .icns)
  2. Run the script again with a .svg image which is not supported, and will restore the original folder icon
  3. Get Info on the Folder, and double-click its image well in the Get Info panel, and press backspace.


Here is an image of the dog cow placed on a folder:


or an .icns with some transparency:


Launch the Script Editor from Dock : Launchpad : Other, and copy/paste the following ASOC source into it. Press its compile button, and then run it. You can save the script as text (applescript), script (.scpt/scptd), or application (.app).


use framework "AppKit"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions

property NSImage : a reference to current application's NSImage
property NSWorkspace : a reference to current application's NSWorkspace
property imgType : {"public.image"}

-- Choose Image first
set theImg to POSIX path of (choose file of type imgType default location (path to desktop) without invisibles)

-- Chose folder next
set theFolder to POSIX path of (choose folder default location (path to desktop))

set imgFile to NSImage's alloc()'s initWithContentsOfFile:theImg
set status to ((NSWorkspace's sharedWorkspace)'s setIcon:imgFile forFile:theFolder options:0) as boolean
return



Translated from a Python/Objective-C script since Apple is vanquishing system installations of Python, Ruby, and Perl in a forthcoming release of macOS.


12 replies
Question marked as Top-ranking reply

Jun 20, 2020 10:01 AM in response to Bruce Kieffer

Here is an AppleScript using Objective-C to select the image, and then select the folder target. It places the image on the folder. There are three ways to revert the folder icon:

  1. Run the script again with a different picture (ideally a .icns)
  2. Run the script again with a .svg image which is not supported, and will restore the original folder icon
  3. Get Info on the Folder, and double-click its image well in the Get Info panel, and press backspace.


Here is an image of the dog cow placed on a folder:


or an .icns with some transparency:


Launch the Script Editor from Dock : Launchpad : Other, and copy/paste the following ASOC source into it. Press its compile button, and then run it. You can save the script as text (applescript), script (.scpt/scptd), or application (.app).


use framework "AppKit"
use AppleScript version "2.4" -- Yosemite or later
use scripting additions

property NSImage : a reference to current application's NSImage
property NSWorkspace : a reference to current application's NSWorkspace
property imgType : {"public.image"}

-- Choose Image first
set theImg to POSIX path of (choose file of type imgType default location (path to desktop) without invisibles)

-- Chose folder next
set theFolder to POSIX path of (choose folder default location (path to desktop))

set imgFile to NSImage's alloc()'s initWithContentsOfFile:theImg
set status to ((NSWorkspace's sharedWorkspace)'s setIcon:imgFile forFile:theFolder options:0) as boolean
return



Translated from a Python/Objective-C script since Apple is vanquishing system installations of Python, Ruby, and Perl in a forthcoming release of macOS.


Jun 21, 2020 4:21 AM in response to Rysz

Image2Icon is perfect for what I need. Took me a bit to figure out how it works since there's little to no info. I always say; "Plug and Play. Plug it in, play around with it until you figure it out." You drag the image into the app's window (circle), then, and this is the step I missed, you drag the folder into the same circle of the app. Boom, photo on folder. Really fast. I did about 30 folders last night in about 5 minutes.

Jun 20, 2020 10:27 AM in response to Bruce Kieffer

I provided the shortest amount of code to get the job done. Even the code to provide one prompt to select the image and the folder would double the code size. Once you add a Cocoa graphical interface with drag and drop capability, then the code would at least quadruple in size and complexity.


Apple is not in the useful, add-on utility business, and I am almost certain they would never build what you want, which is why there is a third-party developer opportunity.


I also have a Python-based Terminal utility that takes a 1024x1024, or 512x512 PNG image and generates an .icns icon bundle from it.

Jun 20, 2020 10:13 AM in response to VikingOSX

Very nice! It does create a square image which is good enough (the shakers are much shorter in reality), and I'm not sure it really saves much time with all the clicking needed, but still very nice. Thanks. I will send feedback to Apple making a request. This could be made as simple as drag the photo onto the folder icon while holding down a modifier key.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use a photo as a folder icon?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.