終了

Someone who understands the script?

New Here ,
Jun 01, 2021 Jun 01, 2021

リンクをクリップボードにコピー

コピー完了

Could anyone fix the code below?
I get an error when I try to save.
Also, when resizing, I want to specify multiple sizes, automatically create a folder with the size name, and save it.
Please lend me your wisdom.


(function(){
    
var arr = new Array();
arr = ["jpg","jpeg","png","gif","psd","bmp"];

//単位をピクセルに変更
preferences.rulerUnits=Units.PIXELS

//対象のフォルダを選択
var folderObj = Folder.selectDialog("フォルダを選択してください");
    if(folderObj===null){
        return;
    }

//幅を入力するダイアログを表示。数字以外入力できないようにする
var regex = false;
while(regex==false){
var n = prompt("幅を指定してください",1500);
var regex = new RegExp(/^[0-9]+$/);
regex = regex.test(n);  
    if(n===null){
        return;
    }
    if(!regex){
        alert("数字を入力してください");  
    }
}

//解像度を入力するダイアログを表示。数字以外入力できないようにする
var regex2 = false;
while(regex2==false){
var reso = prompt("解像度を入力してください",72);
var regex2 = new RegExp(/^[0-9]+$/);
regex2 = regex2.test(reso);  
    if(reso===null){
        return;
    }
    if(!regex2){
        alert("数字を入力してください");  
    }
}

//フォルダ内のファイル全部をフルパスで取得
var fileList = folderObj.getFiles();

for(var i = 0ifileList.lengthi++){
    try{
        var fName = fileList[i].name;//ファイル名だけ取得
        var reg=/(.*)(?:\.([^.]+$))/;
        fName = fName.match(reg)[2];//拡張子だけ取得
    }catch(e){
            $.write("エラー" +'\n');
        }

    //拡張子を調べ、対象のファイルが画像以外ならスキップ
    fName = fName.toLowerCase();
    var isExist = checkExist(arrfName);
    if(isExist==false){
        continue;
    }

    //ファイルを開く
    var fileObj = new File(fileList[i]);
    open(fileObj);
    var flg = fileObj.open("r");

    var ad = activeDocument;
    var x=ad.width//開いたファイルの幅を取得
    var y=ad.height//開いたファイルの高さを取得

    var newX;
    var newY;

    if(x>y){
        newX = parseInt(n);
        newY = (y * newX) / x;
    }else{
      newY = parseInt(n);
      newX = (x * newY) / y;
    }

    //リサイズする
    ad.resizeImage(newXnewYresoResampleMethod.BICUBIC);
    ad.save();
    ad.close(SaveOptions.DONOTSAVECHANGES);
}
alert("完了しました");

})();

function checkExist(arr_str){
    for(var i = 0i<arr_.lengthi++){
            if(str==arr_[i]){
                return true;
             }        
    }
    return false;
 }
 

 

キーワード
macOS , Windows , アクションとスクリプト

表示

112

翻訳

翻訳

レポート

レポート
コミュニティガイドライン
他のユーザーへの思いやりを持ち、敬意を払いましょう。コンテンツの出典を明記し、投稿する前に内容が重複していないか検索してください。 さらに詳しく
community guidelines
Community Expert ,
Jun 01, 2021 Jun 01, 2021

リンクをクリップボードにコピー

コピー完了

Where are you got it?

Ideally, you should contact the author of this script.

And, What version did you run it?

In the latest Photoshop, the saving method may have changed due to OS restrictions.

投票

翻訳

翻訳

レポート

レポート
コミュニティガイドライン
他のユーザーへの思いやりを持ち、敬意を払いましょう。コンテンツの出典を明記し、投稿する前に内容が重複していないか検索してください。 さらに詳しく
community guidelines
Community Expert ,
Jun 02, 2021 Jun 02, 2021

リンクをクリップボードにコピー

コピー完了

最新

I wanna know what error you saw in this code.

投票

翻訳

翻訳

レポート

レポート
コミュニティガイドライン
他のユーザーへの思いやりを持ち、敬意を払いましょう。コンテンツの出典を明記し、投稿する前に内容が重複していないか検索してください。 さらに詳しく
community guidelines