Last active
August 29, 2015 14:23
-
-
Save estum/0c5578ff98c4c76836ad to your computer and use it in GitHub Desktop.
OSX JavaScript: Assign given icon to file or folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env osascript -l JavaScript | |
// ========== | |
// = Usage: | |
// ./assign_icon.jsx TARGET_FILE SOURCE_IMAGE | |
// ========== | |
ObjC.import("Cocoa"); | |
function run(input) { | |
var target_path = input[0].toString(); | |
var source_image = $.NSImage.alloc.initWithContentsOfFile(input[1].toString()); | |
var result = $.NSWorkspace.sharedWorkspace.setIconForFileOptions(source_image, target_path, 0); | |
return target_path; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment