|
1 | 1 | var scriptFilePath = $.fileName; // .js位置 |
2 | 2 | var scriptFolder = new File(scriptFilePath).parent.fsName; // .js文件夹 |
3 | | -var pythonPath = scriptFolder + "\\py3.9\\Scripts\\python.exe"; |
4 | | -var scriptPath = scriptFolder + "\\OpenCC_script.py"; |
| 3 | +//var pythonPath = scriptFolder + "\\py3.9\\Scripts\\python.exe"; |
| 4 | +//var scriptPath = scriptFolder + "\\OpenCC_script.py"; |
| 5 | +var scriptPath = scriptFolder + "\\OpenCC_script.exe" |
5 | 6 | // get psd files |
6 | 7 | var inputFolder = Folder.selectDialog("选择包含PSD文件的文件夹"); |
7 | 8 | var fileList = inputFolder.getFiles("*.psd"); |
@@ -51,9 +52,7 @@ function processLayers(layers) { |
51 | 52 |
|
52 | 53 | // 繁转简 |
53 | 54 | var convertedText = convertText(originalText); |
54 | | - // textItem.contents = convertedText.replace(/\n/g, '\r'); // 需要修改换行符,否则乱码 |
55 | 55 | // var visibleText = convertedText.replace(/\n/g, '\\n'); // 检查换行符 |
56 | | - // logFile.writeln(visibleText) |
57 | 56 |
|
58 | 57 | // 设置字符属性 |
59 | 58 | // 更新文本图层的ActionDescriptor对象 |
@@ -88,10 +87,13 @@ function convertText(text) { |
88 | 87 | inputFile.close(); |
89 | 88 |
|
90 | 89 | // 运行 Python 脚本 |
91 | | - var command = pythonPath + ' "' + scriptPath + '" "' + inputFilePath + '" "' + outputFilePath + '" "' + logFilePath + '"'; |
| 90 | + //var command = pythonPath + ' "' + scriptPath + '" "' + inputFilePath + '" "' + outputFilePath + '" "' + logFilePath + '"'; |
| 91 | + var command = scriptPath + ' "' + inputFilePath + '" "' + outputFilePath + '" "' + logFilePath + '"'; |
92 | 92 | logFile.writeln("Running command: " + command); |
93 | 93 | // logFile.writeln(Folder.current.fsName); |
94 | | - app.system(command); |
| 94 | + var callback = system(command); |
| 95 | + if (callback != 0) |
| 96 | + logFile.writeln("Faild to run python command, callback: " + callback); |
95 | 97 |
|
96 | 98 | // 读取输出文件 |
97 | 99 | var outputFile = new File(outputFilePath); |
|
0 commit comments