Exported JPEG files has "-01" at the end of the file name
Hello All,
I have drafted the script to export the ai to JPEG with resolution 300 PPI and some presets. By executing the script the file was saved with the expected output in the respective selected folder, but the file name has the "-01" at the end.
I know that even if we exporting the ai > JPEG (exporting to the size of Artboard) without script also, it adding the "-01" to the end of the file name.
Whether any possibilities are there to resolve this using script orelse this will come up with -01 at the end of file name.
I am attaching my script as well.
var dest = Folder.selectDialog("Pick a folder and save the JPEG there.");
function main() {
String.prototype.hexEncode = function () {
var hex = '';
for (var i = 0; i < this.length; i++) {
hex += '' + this.charCodeAt(i).toString(16);
}
return hex;
};
function writeFile(fileDestStr, contents) {
var newFile = File(fileDestStr);
newFile.open('w');
newFile.write(contents);
newFile.close();
};
var actiontr = [
"/version 3",
"/name [ 4",
"54657374",
"]",
"/isOpen 1",
"/actionCount 1",
"/action-1 {",
"/name [ 12",
"53617665204d79204a504547",
"]",
"/keyIndex 0",
"/colorIndex 0",
"/isOpen 0",
"/eventCount 1",
"/event-1 {",
"/useRulersIn1stQuadrant 0",
"/internalName (adobe_exportDocument)",
"/localizedName [ 9",
"4578706f7274204173",
"]",
"/isOpen 0",
"/isOn 1",
"/hasDialog 1",
"/showDialog 0",
"/parameterCount 7",
"/parameter-1 {",
"/key 1885434477",
"/showInPalette 0",
"/type (raw)",
"/value < 104",
"0a00000001000000030000000300000000002c0103000000000000000100000069006d006100670065006d00610070000000310000003200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
">",
"/size 104",
"}",
"/parameter-2 {",
"/key 1851878757",
"/showInPalette -1",
"/type (ustring)",
"/value [ PUT_FOLDERPATH_CHAR_LENGTH_HERE",
"PUT_HEX_FOLDERPATH_HERE",
"]",
"}",
"/parameter-3 {",
"/key 1718775156",
"/showInPalette -1",
"/type (ustring)",
"/value [ 16",
"4a5045472066696c6520666f726d6174",
"]",
"}",
"/parameter-4 {",
"/key 1702392942",
"/showInPalette -1",
"/type (ustring)",
"/value [ 12",
"6a70672c6a70652c6a706567",
"]",
"}",
"/parameter-5 {",
"/key 1936548194",
"/showInPalette -1",
"/type (boolean)",
"/value 1",
"}",
"/parameter-6 {",
"/key 1935764588",
"/showInPalette -1",
"/type (boolean)",
"/value 1",
"}",
"/parameter-7 {",
"/key 1936875886",
"/showInPalette -1",
"/type (ustring)",
"/value [ 1",
"31",
"]",
"}",
"}",
"}"
].join("\n");
if (app.documents.length == 0) {
return;
}
var destStr = decodeURI(dest.fsName);
var actionFileDestStr = Folder.desktop + "/MyAction.aia";
writeFile(actionFileDestStr, actiontr.replace("PUT_FOLDERPATH_CHAR_LENGTH_HERE", destStr.length).replace("PUT_HEX_FOLDERPATH_HERE", destStr.hexEncode()));
var actionFile = File(actionFileDestStr);
app.loadAction(actionFile);
app.doScript("Save My JPEG", "Test");
//clean up
actionFile.remove();
app.unloadAction("Test", '');
};
main();
