skip to Main Content

Well, the header kind of says it all.

How do I, in a Photoshop script, get the name of the operating system?
I need it to determine the syntax for the save path of the files.

3

Answers


  1. The app.systemInformation property returns a string which includes the OS, among other system properties.

    You can do something like:

    var infoStrings = app.systemInformation.split('n');
    var os
    
    infoStrings.forEach(function(str) {
        if (str.includes('Operating System') {
            var osNameIndex = str.indexOf(':') + 2;
            os = str.substr(osNameIndex);
        }
    });
    
    console.log(os) // Should output the name of the current OS
    
    Login or Signup to reply.
  2. This is what I use to determine the os:

    var fileLineFeed = "";
    
    if ($.os.search(/windows/i) != -1) {
        fileLineFeed = "Windows";
    } else {
        fileLineFeed = "Macintosh";
    }
    

    It works for me as my users are only using one of those two operating systems.

    Login or Signup to reply.
  3. Since you need to determine the syntax for the save path of the files, the name of the file system is possibly the most appropriate:

    alert (File.fs);    // "Macintosh", "Unix", "Windows"
    

    Information about File.fs and $.os can be found in the document JavaScript Tools Guide (p. 48 and 218 respectively).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search