2016-12-05 8 views
0

私はちょうどPhotoshopのプロセスを自動化するためにjavascriptを作ろうとしましたが、完了したらその部分を私の履歴に表示したくありません。どうやってするの?私は、すべての履歴ログをパージする必要はないことを意味します。スクリプトによって実行されるもののみ。Photoshopの履歴の一部を非表示にする

ありがとうございました

+0

最近のファイルの配列である悲しい 'recentFiles'は読み取り専用です。配列からファイルを削除する方法はありません。イメージ処理(スクリプトできない)の後でFile> Clear Recent Fileを使用することはできません –

答えて

0

スクリプトで最新のファイルリストを消去することはできません。 recentFilesは読み取り専用なので、スクリプトを使用して削除することもできません。

ただし、最近のファイルのコピーを作成して、すべての処理をリストに逆戻りして戻してもかまいません。そのため、最近のファイルリストは見つかったものと正確に同じです。

// recentFiles.length = 0; // doesn't work 


// get only existing recent files 
var myRecentItems = []; 
var s= ""; 
var len = recentFiles.length -1; 
var myTempDirectoryName = "c:\\temp"; 


for (var i = 0; i < recentFiles.length; i++) 
{ 
    var r = recentFiles[i]; 
    if (r.exists) 
    { 
     // alert(r + " exists!"); 
     myRecentItems.push(r); 
     s+= r + "\n"; 
    } 
} 

alert(myRecentItems.length); 

// set to zero 
set_recent_file_length(0); 

// DO STUFF HERE 
// or in this case create small images 
// with random names to pad out the recent files list 

// create new images 
for (var i = 0; i < myRecentItems.length; i++) 
{ 
    var n = get_random_string(8) + ".psd"; 
    create_new_document(10,10, 72, n); 
    // Set savePath and fileName to source path 
    var PSDfile = myTempDirectoryName + "\\" + n; 
    save_psd(PSDfile); 
} 

// END DO STUFF 


// Load the lrecent files list as we found it 
// get the old images back 
for (var i = len; i >= 0; i--) 
{ 
    var r = recentFiles[i]; 
    // open the files in reverse order 
    open_image(r); 
    //close that document without saving 
    app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); 
} 

set_recent_file_length(len); 


function create_new_document(w, h, imageres, docname) 
{ 
    var docRef = app.documents.add(w, h, imageres, docname); 
} 

function open_image(f) 
{ 
    try 
    { 
     var idOpn = charIDToTypeID("Opn "); 
     var desc74 = new ActionDescriptor(); 
     var idnull = charIDToTypeID("null"); 
     desc74.putPath(idnull, new File(f)); 
     executeAction(idOpn, desc74, DialogModes.NO); 
    } 
    catch(e) 
    { 
    alert("Oops!\n" + f + "\n" + e); 
    } 
} 

function save_psd(f) 
{ 
    // save out the image 
    var psdFile = new File(f); 
    psdSaveOptions = new PhotoshopSaveOptions(); 
    psdSaveOptions.embedColorProfile = true; 
    psdSaveOptions.alphaChannels = true; 
    activeDocument.saveAs(psdFile, psdSaveOptions, false, Extension.LOWERCASE); 
    // close that saved psd 
    app.activeDocument.close() 
} 


function set_recent_file_length(num) 
{ 
    var idsetd = charIDToTypeID("setd"); 
    var desc9 = new ActionDescriptor(); 
    var idnull = charIDToTypeID("null"); 
    var ref5 = new ActionReference(); 
    var idPrpr = charIDToTypeID("Prpr"); 
    var idGnrP = charIDToTypeID("GnrP"); 
    ref5.putProperty(idPrpr, idGnrP); 
    var idcapp = charIDToTypeID("capp"); 
    var idOrdn = charIDToTypeID("Ordn"); 
    var idTrgt = charIDToTypeID("Trgt"); 
    ref5.putEnumerated(idcapp, idOrdn, idTrgt); 
    desc9.putReference(idnull, ref5); 
    var idT = charIDToTypeID("T "); 
    var desc10 = new ActionDescriptor(); 
    var idlegacyPathDrag = stringIDToTypeID("legacyPathDrag"); 
    desc10.putBoolean(idlegacyPathDrag, true); 
    var idvectorSelectionModifiesLayerSelection = stringIDToTypeID("vectorSelectionModifiesLayerSelection"); 
    desc10.putBoolean(idvectorSelectionModifiesLayerSelection, true); 
    var idGnrP = charIDToTypeID("GnrP"); 
    desc9.putObject(idT, idGnrP, desc10); 
    executeAction(idsetd, desc9, DialogModes.NO); 
    var idsetd = charIDToTypeID("setd"); 
    var desc11 = new ActionDescriptor(); 
    var idnull = charIDToTypeID("null"); 
    var ref6 = new ActionReference(); 
    var idPrpr = charIDToTypeID("Prpr"); 
    var idFlSP = charIDToTypeID("FlSP"); 
    ref6.putProperty(idPrpr, idFlSP); 
    var idcapp = charIDToTypeID("capp"); 
    var idOrdn = charIDToTypeID("Ordn"); 
    var idTrgt = charIDToTypeID("Trgt"); 
    ref6.putEnumerated(idcapp, idOrdn, idTrgt); 
    desc11.putReference(idnull, ref6); 
    var idT = charIDToTypeID("T "); 
    var desc12 = new ActionDescriptor(); 
    var idRcnf = charIDToTypeID("Rcnf"); 
    desc12.putInteger(idRcnf, num); 
    var idFlSv = charIDToTypeID("FlSv"); 
    desc11.putObject(idT, idFlSv, desc12); 
    executeAction(idsetd, desc11, DialogModes.NO); 
} 


function get_random_string(len) 
{ 
    var chars = "abcdefghijklmnopqrstuvwxyz"; 
    var randString = ""; 
     for (i=0; i<len; i++) 
     { 
      var rnd = Math.floor(Math.random()* chars.length); 
      randString += chars.substring(rnd, rnd +1) 
     } 
     return randString; 
} 
+0

は解決策を見つけました。それは魔法のように機能し、extendscriptとその偉大さを試しました –

関連する問題