Skip to main content
Pedro Cortez Marques
Legend
August 13, 2013
Question

Possible to change folder icon using app.system()? [PC/mac]

  • August 13, 2013
  • 1 reply
  • 1784 views

I need help to verify if this works smoothly.

... If it is even possible...

#target bridge;

if ( BridgeTalk.appName == "bridge" ) {

     if ( Folder.fs == "Macintosh" ) {

          iconPath = new File("/someplace/MyIcon.icns");

          var myFolder = new Folder("/someplace");

          // select my folder and tell OSX to change the icon to MyIcon.icns

          app.system("mac command lines");

     } else if ( Folder.fs == "Windows" ) {

          iconPath = new File("/someplace/MyIcon.ico");

          myFolder = new Folder("/someplace");

          // select my folder and tell OSX to change the icon to MyIcon.ico

          app.system("command code"); // for windows7

     } else {

          alert ("Unsupported file system");

     }

}

This topic has been closed for replies.

1 reply

Inspiring
August 13, 2013

Im not sure you can do this… Im only speaking from the mac point of view… I have done this in the past with AppleScript.

There was no in-built apple shell to this and I needed to use a third party utility…

http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html

http://osxutils.sourceforge.net/

It may also be possible using the apple developer tools if they are installed…

Pedro Cortez Marques
Legend
September 2, 2013

I just have done this for Mac and it works.

I had to create an app from applescript that reads an xml with the 2 paths (the icon image path and the folder/file path to put the icon)

This app has also the shell command to add the icon.

Putting all the files on the right places, I just add to update the xml with the image new icon and the file/folder path and then call the app from the app.system that reads the file.

If the file to change the icon is from the Users directory, it works fine, If it is from the network I have to add /Volumes/ before its path.