LoginSignup
0

More than 5 years have passed since last update.

[Photoshop Script] 元からあるスクリプトを改変して./outputディレクトを作りそこへ出力するようにする

Last updated at Posted at 2015-03-31

環境

  • Windows 8.1 Pro
  • Adobe Photoshop CS6

目標

出力時にactiveDocumentのディレクトリの中にoutputディレクトを作り、そこがデフォルトの出力先になるようにするコードを追加する。
追加対象は、例えば Export Layers To Files.jsx がある。

トラップ

何も考えないで次のコードを加えると

var outputDirPath = activeDocument.path + "/output";

パスに日本語を含むとき、dlgMain.etDestination.textで当該部分が化ける(パーセントエンコーディング?)。

修正

ググると出てくるのはpath.fsNameを利用する方法である。
筆者はWindows/MacOSに両対応(?)させたかったので、パスを作った後Folderオブジェクトを作り、正しいパスを得る(fsName)。

var outputDirPath = activeDocument.path + "/output";
var outputDir = Folder(outputDirPath);
var fsOutputDirPath = outputDir.fsName.toString();
dlgMain.etDestination.text = fsOutputDirPath;
//Check if it exist, if not create it.
if(!outputDir.exists) outputDir.create(); 

問題

Mac版でうまくいくかは未検証 :sweat_drops:

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0