Copy link to clipboard
Copied
Hi EveryOne,
I need to change my finder label color of file. However i get the script from Adobe forums (Re: Change Color Label of File with Javascript)
The below mentioned script getting error. Please rectify that or tell me the alternate solution.
Thanks to Christoper and Muppet Mark-QAl63s.
//myscript.sh MUST exist with execute permissions!
var script = new File("~/Desktop/myscript.sh");
var filePath=new File("~/Desktop/Source1.tif");
script.length = 0;
script.lineFeed = "unix";
script.length = 0;
script.open("e");
script.writeln("#!/bin/bash");
script.writeln('Tell application "Finder" to set label index of (POSIX file "' + decodeURI(filePath) + '") to 2');
script.close();
script.execute();
-yajiv
And why
var filePath=new File("/Volumes/System SSD/Users/yajiv/Desktop/Source1.tif");
instead of
var filePath = "/Volumes/System SSD/Users/yajiv/Desktop/Source1.tif";
?
Copy link to clipboard
Copied
I think you need to amend the path (see the example where the file would be on the HD "System SSD" and the user would be "pfaffenbichler") and you can use app.system.
#target photoshop
app.bringToFront();
var filePath= "/Volumes/System SSD/Users/pfaffenbichler/Desktop/Source1.tif";
app.system( 'osascript -e \'tell application "Finder" to set label index of file ((POSIX file \"'+filePath+'\") as alias) to 2\'');
Copy link to clipboard
Copied
Hi Chris,
Thanks for your valuable reply. This code not working in my system.
Please suggest me what was wrong!
#target photoshop
app.bringToFront();
var filePath=new File("/Volumes/System SSD/Users/yajiv/Desktop/Source1.tif");
app.system( 'osascript -e \'tell application "Finder" to set label index of file ((POSIX file \"'+filePath+'\") as alias) to 2\'');
-yajiv
Copy link to clipboard
Copied
Just to make sure: Are you working on a Mac?
Is the file "Source1.tif" definitely located on your startup disk and desktop and is it named "System SSD"?
Copy link to clipboard
Copied
Please open the file in Photoshop, ctrl-click the filename and post a screenshot thereof, like this:
Copy link to clipboard
Copied
And why
var filePath=new File("/Volumes/System SSD/Users/yajiv/Desktop/Source1.tif");
instead of
var filePath = "/Volumes/System SSD/Users/yajiv/Desktop/Source1.tif";
?
Copy link to clipboard
Copied
Hi Chris,
it working like a charm..
Thanks you so much for your kind help..
-yajiv
Copy link to clipboard
Copied
Good to know it worked out.