3 Replies Latest reply: Jul 15, 2014 3:25 AM by Pedro Marques RSS

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

    Pedro Marques Community Member

      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");

           }

      }

        • 1. Re: Possible to change folder icon using app.system()?  [PC/mac]
          Muppet Mark Community Member

          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…

          • 2. Re: Possible to change folder icon using app.system()?  [PC/mac]
            Pedro Marques Community Member

            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.

             

             

            • 3. Re: Possible to change folder icon using app.system()?  [PC/mac]
              Pedro Marques Community Member

              var f=new File(app.document.presentationPath  + "/desktop.ini");

              f.open('w');

              f.encoding = "UTF8";

              f.writeln("[.ShellClassInfo]");

              // I have chosen one icon of windows7, but you can design and create your own icon, export it to .ico and add it here, for ex: f.writeln("IconResource=c:\\Users\\Public\\myIcons\\myicon.ico");

              f.writeln("IconResource=%windir%\\system32\\imageres.dll,101"); // if using dll of windows, a 2nd argument is needed to set the number of the icon (there are several possible dll libraries with hundreds of icons)

              f.writeln("[ViewState]");

              f.writeln("Mode=");

              f.writeln("Vid=");

              f.writeln("FolderType=Pictures");

              f.close();

              .hidden=true;

              //

              var cmd = "attrib +s  \"" + decodeURI(app.document.presentationPath) + "\"";

              app.system(cmd);

              // go to the parent folder to refresh and come back again:

              var back = app.document.thumbnail.uri;

              app.document.thumbnail = app.document.thumbnail.parent;

              app.document.thumbnail.refresh();

              app.document.thumbnail = new Thumbnail(back);