save all open files to tiff with same name and same size, but add space for every file name
I need a code that saves all files opened on Photoshop in TIFF format,
but I work on many files that are similar in terms of name and size and I have a code that saves files in this format, but I want to separate similar files by adding a space in each name so that the file is not saved the other on it
- Also, for clarification.. I am working on many files with sizes 100*70 and I want to save them all with one name only by entering the name inside the edittext
- This is the code I'm working with, but it's very long and complicated
I want to simplify the code as much as possible
// manually save det destination folder
dlg = new Window("dialog"); dlg.text = "Enter the Name To Save All File With Same Name"; dlg.preferredSize.width = 200; dlg.preferredSize.height = 100;
var Mat = dlg.add ("edittext", [0,0,200,50]); Mat.active=true;
Size=dlg.add("button", undefined, " OK" ); Size.alignChildren = ['fill', 'fill'];
Mat.active=true;
var Path = Folder.selectDialog("Choose folder to save files to");
Size.onClick = function () {
dlg.hide();
//Get time from getTime function
var time = getTime();
//HELPER FUNCTIONS
function getTime(){
var currentTime = new Date();
var timeOfDay;
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var Seconds = currentTime.getSeconds();
//Make timestamp
//var timeStamp = day + "-" + month + "-" + year + " " + hours + "-" + minutes+ "-" + Seconds ;
//var timeStamp = hours + "-" + minutes+ "-" + Seconds ;
var timeStamp = minutes+ "-" + Seconds ;
//var timeStamp = Seconds ;
return timeStamp;
}
for (var i=0; i<app.documents.length; i++) {
var doc = app.activeDocument = app.documents[i],
num = i + 1;
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
if (tiffFile.exists === true) {
tiffFile = File(Path + "/" + "♥"+ "("+num+")" +"♥"+" "+ Mat.text + " "+ " " + Math.round(doc.width)+ " " + Math.round(doc.height) + ".tif");
}
}
}
}
}
}
}
}
}
app.activeDocument.flatten();
app.activeDocument.changeMode(ChangeMode.CMYK);
activeDocument.bitsPerChannel = BitsPerChannelType.EIGHT;
app.preferences.rulerUnits = Units.CM; app.preferences.typeUnits = TypeUnits.MM;
var strokeColor = new SolidColor;
strokeColor.cmyk.cyan = 0;
strokeColor.cmyk.magenta = 0;
strokeColor.cmyk.yellow = 0;
strokeColor.cmyk.black = 100;
app.activeDocument.selection.selectAll();
app.activeDocument.selection.stroke(strokeColor, 3, StrokeLocation.CENTER);
app.activeDocument.selection.deselect();
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
//tiffSaveOptions.alphaChannels = true;
//tiffSaveOptions.layers = true;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
//tiffSaveOptions.layerCompression=LayerCompression.ZIP;
//tiffSaveOptions.jpegQuality=10;
activeDocument.saveAs(tiffFile, TiffSaveOptions, true, Extension.LOWERCASE);
//Restor File To First History record
//app.activeDocument.activeHistoryState = savedState
//Close the current document without saving:
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
while (app.documents.length > 0) {
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
}
dlg.show();