One linerThis is possible using swift:
swift -e 'import Cocoa; NSWorkspace.shared.setIcon(NSImage(contentsOfFile: "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DownloadsFolder.icns"), forFile: "/Users/jmurphy/Documents/testfolder")' import Cocoa let iconSystemFolderPath = "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources" let iconFilePath = "\(iconSystemFolderPath)/DownloadsFolder.icns" let iconImage = NSImage(contentsOfFile: iconFilePath) let folderPath = "/Users/jmurphy/Documents/testfolder" NSWorkspace.shared.setIcon(iconImage, forFile: folderPath) You can turn it into a one liner:
swift -e 'import Cocoa; NSWorkspace.shared.setIcon(NSImage(contentsOfFile: "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/DownloadsFolder.icns"), forFile: "/Users/jmurphy/Documents/testfolder")' Tested on macOS 13.5