在Photoshop脚本中获取OS的名称

时间:2017-08-23 21:22:03

标签: javascript photoshop photoshop-script

好吧,标题就说明了一切。

如何在Photoshop脚本中获取操作系统的名称? 我需要它来确定文件保存路径的语法。

3 个答案:

答案 0 :(得分:1)

app.systemInformation属性返回一个字符串,其中包含操作系统以及其他系统属性。

您可以执行以下操作:

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

答案 1 :(得分:0)

这是我用来确定os:

Entry

它适用于我,因为我的用户只使用这两种操作系统中的一种。

答案 2 :(得分:0)

由于您需要确定文件保存路径的语法,因此文件系统的名称可能是最合适的:

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

有关File.fs$.os的信息,请参阅文档JavaScript Tools Guide(分别为第48页和第218页)。