Hello
I want to change the icon in the Finder.
I have several colored icons available.
I want to color the session data icons for better visibility of the data I'm working on.
Here's an example of a place where I have an icon

The contents of this folder are empty and exist only for the icons.
Here's my script as it stands now.
It works fine, but I feel it's too redundant.
Is there any way to make it more concise?
This script is for a red folder.
sf.ui.finder.menuClick({
menuPath: ["File","Get Info"],
});
sf.keyboard.press({
keys: "cmd+shift+g",
});
sf.wait({
intervalMs: 50,
});
sf.keyboard.press({
keys: "slash",
});
sf.ui.finder.mainWindow.sheets.first.comboBoxes.first.elementSetTextFieldWithAreaValue({
value: "~/Desktop/icon/",
});
sf.ui.finder.mainWindow.sheets.first.getElement('AXDefaultButton').elementClick();
sf.wait({
intervalMs: 50,
});
sf.keyboard.press({
keys: "f",
});
sf.wait({
intervalMs: 50,
});
sf.ui.finder.menuClick({
menuPath: ["File","Get Info"],
});
sf.keyboard.press({
keys: "tab",
});
sf.ui.finder.menuClick({
menuPath: ["Edit","Copy"],
});
sf.wait({
intervalMs: 50,
});
sf.ui.finder.menuClick({
menuPath: ["File","Close Window"],
});
sf.wait({
intervalMs: 500,
});
sf.ui.finder.menuClick({
menuPath: ["Window","Cycle Through Windows"],
});
sf.wait({
intervalMs: 50,
});
sf.keyboard.press({
keys: "tab",
});
sf.ui.finder.menuClick({
menuPath: ["Edit","Paste"],
});
sf.wait({
intervalMs: 50,
});
sf.ui.finder.menuClick({
menuPath: ["File","Close Window"],
});
- Kitch Membery @Kitch2020-11-10 10:37:31.097Z2020-11-10 10:46:53.424Z
Hi @Yujiro_Yonetsu,
Something like this should do it;
const iconFolderPath = 'Desktop/Icons/Final Mix'; const destinationFolderPath = 'Desktop/Destination'; function copyIcon(iconFolderPath) { sf.system.exec({ commandLine: `open -R "${iconFolderPath}"`, }); sf.ui.finder.menuClick({ menuPath: ["File", "Get Info"], }); sf.ui.finder.windows.whoseTitle.endsWith('Info').first.elementWaitFor(); sf.keyboard.press({ keys: "tab", }); sf.wait({ intervalMs: 200 }); sf.ui.finder.menuClick({ menuPath: ["Edit", "Copy"], }); sf.ui.finder.menuClick({ menuPath: ["File", "Close Window"], }); sf.ui.finder.windows.whoseTitle.endsWith('Icon').first.elementWaitFor({ waitType: 'Disappear' }); } function pasteIcon(destinationFolder) { sf.system.exec({ commandLine: `open -R "${destinationFolder}"`, }); sf.ui.finder.menuClick({ menuPath: ["File", "Get Info"], }); sf.ui.finder.windows.whoseTitle.endsWith('Info').first.elementWaitFor(); sf.keyboard.press({ keys: "tab", }); sf.wait({ intervalMs: 200 }); sf.ui.finder.menuClick({ menuPath: ["Edit", "Paste"], }); sf.ui.finder.menuClick({ menuPath: ["File", "Close Window"], }); sf.ui.finder.windows.whoseTitle.endsWith('Icon').first.elementWaitFor({ waitType: 'Disappear' }); } function main() { sf.ui.finder.appActivate(); sf.ui.finder.appWaitForActive(); copyIcon(iconFolderPath); sf.wait({ intervalMs: 300 }); pasteIcon(destinationFolderPath); } main();
Just change the
iconFolderPath
&destinationFolderPath
:-)Yujiro Yonetsu @Yujiro_Yonetsu
Thank you for your advice.
I feel like I'm definitely getting closer to my hopes.But as far as the destination folder is concerned, I'd like to specify the file that is always selected.
What changes should be made to achieve this?
Please.Kitch Membery @Kitch2020-11-10 19:41:50.885Z
Just change the "Destination Folder Path" to this
const destinationFolderPath = sf.ui.finder.firstSelectedPath;
Yujiro Yonetsu @Yujiro_Yonetsu
Thank you!