命令
- 如果是cmd中的话
"C:\Program Files\Adobe\Adobe Photoshop CC 2019\Photoshop.exe" "C:\Users\etrump\AppData\Roaming\hellofont\ps1.jsx",直接写ps路径和需要操作的jsx文件路径
- 如果是在node中
exec(cmdStr, {}, (err, stdout, stderr) => {console.log('其他操作')})可以通过exec去执行控制台命令
具体代码
- 首先要知道jsx是指Adobe ExtendScript脚本,利用脚本去完成操作
String.prototype.endsWith = function(sub) {
return this.length >= sub.length &&
this.slice(this.length - sub.length) == sub
}
function Main() {
// 当前文件路径
var ScriptFilePath = Folder($.fileName).parent.fsName
var resultLog = File(ScriptFilePath + '/psGetPathsResultLog.txt') // 新生成存结果的文件
var doneLog = File(ScriptFilePath + '/psGetPathsDoneLog.txt')
resultLog.encoding = 'UTF8'
resultLog.open('w', 'TEXT', '????')
doneLog.encoding = 'UTF8'
doneLog.open('w', 'TEXT', '????')
if(app.documents.length != 0) {
for(var i = 0
var doc = app.documents[i]
var path = doc.fullName
var name = doc.name
if (name.endsWith('.psd')) {
resultLog.write(path + '
}
}
}
resultLog.close()
doneLog.write('1')
doneLog.close()
}
try {
Main()
} catch(e) {
}