Files
cutdex/tool/macos/set_macos_file_icon.swift
T
lingjhf 27e77fff39 feat: initial Cutdex application
Add the Flutter video editing application with project management, media
import, timeline editing, preview, AI assistance, diagnostics and settings.

Include shared UI and native host packages, platform runners, application
tests and release tooling.

Provide usage and contribution guides, the MIT license and third-party
notices. Exclude local credentials, build outputs and validation data.
2026-10-05 23:36:23 +08:00

20 lines
624 B
Swift

import AppKit
import Foundation
let arguments = Array(CommandLine.arguments.dropFirst())
let usage = "Usage: swift set_macos_file_icon.swift <icon-file> <target-file>\n"
if arguments == ["--help"] || arguments == ["-h"] {
print(usage, terminator: "")
exit(0)
}
guard arguments.count == 2 else {
fputs(usage, stderr)
exit(2)
}
guard FileManager.default.fileExists(atPath: arguments[1]),
let icon = NSImage(contentsOfFile: arguments[0]),
NSWorkspace.shared.setIcon(icon, forFile: arguments[1], options: []) else {
fputs("Failed to set file icon: verify the icon and target paths\n", stderr)
exit(1)
}