I tend to work with patterns and have an action to help with this. But, I tend to save my patterns as a .pat file, with anywhere from 10-200 patterns within each .pat file. I am trying to figure out a way to set up an action to create a new pattern fill layer, save it, and then replace the pattern in the fill layer with the next pattern in the .pat file.
What I've got so far...
I open a new file in the size I want (1000x1000 to 9000x5000 depending on what I need)
Set up the Adjustments for all such patterns in that specific folder
Record a new action
New Fill Layer > Pattern
Select the first pattern in the pattern folder for that specific .pat file
Save the file at highest quality
Stop recording the action
Play action - except it only selects the first pattern in that specific pattern folder.
How would I set this up so that, I dunno, I select the pattern folder I am wanting to work with (or .pat file), and then it will select a fill layer with the first pattern, save it, and when run again, it will select the 2nd, then 3rd, and so on so that I can do a batch to get them all saves individually in all the different sizes I want/need?
EDIT: Here is a script for applying the newest made pattern to a fill layer, though it does nothing but select the newest pattern in a .pat file instead of selecting the 1st, then 2nd, and so on
#target photoshop;
main();
function main() {
if (!documents.length) return;
var patt = new File(Folder.temp + "/tempPatterns");
if (patt.exists) patt.remove();
savePatterns(patt);
var patterns = getPatternsFromFile(patt);
fillPattern(patterns[patterns.length - 1][0].toString(), patterns[patterns.length - 1][1].toString(), 100);
};
function savePatterns(file) {
var desc625 = new ActionDescriptor();
desc625.putPath(charIDToTypeID('null'), new File(file));
var ref462 = new ActionReference();
ref462.putProperty(charIDToTypeID('Prpr'), charIDToTypeID('Ptrn'));
ref462.putEnumerated(charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));
desc625.putReference(charIDToTypeID('T '), ref462);
executeAction(charIDToTypeID('setd'), desc625, DialogModes.NO);
};
function getPatternsFromFile(file) {
file.open("r");
file.encoding = 'BINARY';
var str = file.read();
file.close();
var patterns = [];
var re = /(\x00\w|\x00\d)(\x00\-|\x00\w|\x00\s|\x00\d)+\x00\x00\$[-a-z\d]+/g;
var parts = str.match(re);
for (var i = 0; i < parts.length; i++) {
var p = parts;
var sp = p.replace(/\x00/g, '').split('$');
patterns.push([
[sp[0]],
[sp[1]]
]);
}
return patterns;
};
function fillPattern(name, id, opacity) {
var desc6 = new ActionDescriptor();
desc6.putEnumerated(charIDToTypeID('Usng'), charIDToTypeID('FlCn'), charIDToTypeID('Ptrn'));
var desc7 = new ActionDescriptor();
desc7.putString(charIDToTypeID('Nm '), name);
desc7.putString(charIDToTypeID('Idnt'), id);
desc6.putObject(charIDToTypeID('Ptrn'), charIDToTypeID('Ptrn'), desc7);
desc6.putUnitDouble(charIDToTypeID('Opct'), charIDToTypeID('#Prc'), opacity);
desc6.putEnumerated(charIDToTypeID('Md '), charIDToTypeID('BlnM'), charIDToTypeID('Nrml'));
try {
executeAction(charIDToTypeID('Fl '), desc6, DialogModes.NO);
} catch (e) {}
};