前回は同じ画像/図を大量に縦横に並べるものでした。今回は同じ画像でなく異なる複数の写真を大量に縦横に並べるものです。基本的には前回のスクリプトと同じですが、並べる写真があるフォルダを指定する必要があります。また、指定したフォルダ内にある写真の枚数以上は処理しないようになっています。
function multiCopy()
			{
			 folderObj = Folder.selectDialog("フォルダを選択してください");
			 w = parseInt(prompt("横の枚数",3));
			 h = parseInt(prompt("縦の枚数",2));
			 stepW = parseInt(prompt("横の間隔",100));
			 stepH = parseInt(prompt("縦の間隔",80));
			 fileList = folderObj.getFiles("*.jpg");
			 i = 0;
			 for (y=0; y<h; y++)
			 {
			  for (x=0; x<w; x++)
			  {
			   fileObj = new File(fileList[i]);
			   open(fileObj);
			   activeDocument.selection.selectAll();
			   activeDocument.selection.copy();
			   activeDocument.close(SaveOptions.DONOTSAVECHANGES);
			   activeDocument.paste();
			   activeDocument.activeLayer.translate(x*stepW,y*stepH);
			   i++;
			   if (i >= fileList.length) return;
			  }
			 }
			}
			multiCopy();
このスクリプトでは写真の枚数が少ないとタイル状に配置したくてもできないことになります。3枚の写真しかないが、これを繰り返して配置したい場合には
if (i >= fileList.length) return;
を
if (i >= fileList.length) i = 0;
にすると画像の枚数分だけ同じ写真を繰り返し配置するようになります。
			上記のスクリプトは規則正しく画像を並べますが、ランダムに並べたいこともあります。そのような場合いは乱数を使い、適度な範囲で位置がずれるようにします。
function multiCopy()
			{
			 folderObj = Folder.selectDialog("フォルダを選択してください");
			 w = parseInt(prompt("横の枚数",3));
			 h = parseInt(prompt("縦の枚数",2));
			 stepW = parseInt(prompt("横の間隔",100));
			 stepH = parseInt(prompt("縦の間隔",80));
			 diffW = parseInt(prompt("横のずれ",30));
			 diffH = parseInt(prompt("縦のずれ",30));
			 fileList = folderObj.getFiles("*.jpg");
			 i = 0;
			 for (y=0; y<h; y++)
			 {
			  for (x=0; x<w; x++)
			  {
			   fileObj = new File(fileList[i]);
			   open(fileObj);
			   activeDocument.selection.selectAll();
			   activeDocument.selection.copy();
			   activeDocument.close(SaveOptions.DONOTSAVECHANGES);
			   activeDocument.paste();
			   dx = Math.random() * diffW - diffW/2;
			   dy = Math.random() * diffH - diffH/2;
			   activeDocument.activeLayer.translate(x*stepW+dx,y*stepH+dy);
			   i++;
			   if (i >= fileList.length) return;
			  }
			 }
			}
			multiCopy();
さらに回転もしたいのであれば以下のようになります。
function multiCopy()
			{
			 folderObj = Folder.selectDialog("フォルダを選択してください");
			 w = parseInt(prompt("横の枚数",3));
			 h = parseInt(prompt("縦の枚数",2));
			 stepW = parseInt(prompt("横の間隔",100));
			 stepH = parseInt(prompt("縦の間隔",80));
			 diffW = parseInt(prompt("横のずれ",30));
			 diffH = parseInt(prompt("縦のずれ",30));
			 rot = parseInt(prompt("回転角度",30));
			 fileList = folderObj.getFiles("*.jpg");
			 i = 0;
			 for (y=0; y<h; y++)
			 {
			  for (x=0; x<w; x++)
			  {
			   fileObj = new File(fileList[i]);
			   open(fileObj);
			   activeDocument.selection.selectAll();
			   activeDocument.selection.copy();
			   activeDocument.close(SaveOptions.DONOTSAVECHANGES);
			   activeDocument.paste();
			   dx = Math.random() * diffW - diffW/2;
			   dy = Math.random() * diffH - diffH/2;
			   r = Math.random() * rot - rot/2;
			   activeDocument.activeLayer.translate(x*stepW+dx,y*stepH+dy);
			   activeDocument.activeLayer.rotate(r,AnchorPosition.MIDDLECENTER);
			   i++;
			   if (i >= fileList.length) return;
			  }
			 }
			}
			multiCopy();