Copy link to clipboard
Copied
#target illustrator
var doc = app.activeDocument;
var allText = doc.textFrames;
var boldText = app.textFonts.getByName("Arial-Black")
var d = new Date();
var currentYear = d.getFullYear();
var currentMonth = ("0"+(d.getMonth()+1)).slice(-2);
var currentDay = ("0" + (d.getDate())).slice(-2)
for (var i = 0; i < allText.length; i++) {
//alert(allText.contents.substr(0,4));
if (allText.contents == "Electrical System") {
//alert("This is an Electrical Schematic");
var mediaType = allText.contents;
}
if (allText.contents.substr(0, 4) == "UENR") {
//alert("Media Number " + allText.contents);
var mediaNumber = allText.contents;
}
var textFieldRange = allText.textRange;
var textProps = textFieldRange.characterAttributes;
if (allText.contents != "Electrical System" && textProps.textFont == "[TextFont Arial-Black]") {
//alert("Your Title is: " + allText.contents);
var mediaTitle = allText.contents;
}
}
var emailAddress = "someone@myemail.com";
var dateFormat = currentYear + "" + currentMonth + "" + currentDay;
//alert("Media #: " + mediaNumber + "\nMedia Type: " + mediaType + "\nTitle: " + mediaTitle + "\nEmail report to: " + emailAddress + "\nSubmitted on: " + dateFormat);
So I am wanting to take the information from the above script I wrote and have a text file of sorts in a certain format. For example I would like this format
<meta name="Internet E-Mail Address" content="emailAddress">
<meta name="Media No Rev" content="mediaNumber">
<meta name="Publication Date" content="dateFormat">
so a finished report would look like this for example:
<meta name="Internet E-Mail Address" content="someone@myemail.com">
<meta name="Media No Rev" content="UENR1234">
<meta name="Publication Date" content="20160226">
Here is how I'd do this.
Start out with a string.
var str = '<meta name="Internet E-Mail Address" content="' + emailAddress + '">\r' +
'<meta name="Media No Rev" content="' + mediaNumber + '">\r' +
'<meta name="Publication Date" content="' + dateFormat + '">\r';
Then, write it to a text file.
var f = File("~/Desktop/myFile.txt);
f.open('w');
f.write(str);
f.close();
Copy link to clipboard
Copied
Here is how I'd do this.
Start out with a string.
var str = '<meta name="Internet E-Mail Address" content="' + emailAddress + '">\r' +
'<meta name="Media No Rev" content="' + mediaNumber + '">\r' +
'<meta name="Publication Date" content="' + dateFormat + '">\r';
Then, write it to a text file.
var f = File("~/Desktop/myFile.txt);
f.open('w');
f.write(str);
f.close();
Copy link to clipboard
Copied
That worked PERFECT!
Thanks so much Silly-V‌!!
Copy link to clipboard
Copied
Silly-V‌ Is there a way to create this html file in a dynamic folder location?
So I have this code to create a folder.....
var mediaFolder = new Folder ("C:\\Users\\wolfecj\\Desktop\\" + mediaNumber.substring(0, 8)); |
mediaFolder.create();
So I want this file....
var f = File("~/Desktop/" + mediaNumber.substr(0, 8) + ".html");
f.open('w');
f.write(str);
f.close();
Written into the folder location I have.
I know I can't write it like this exactly but this is the concept of what I am looking for:
var f = File("~/mediaFolder" + mediaNumber.substr(0, 8) + ".html");
Any thoughts?
Copy link to clipboard
Copied
Looks like you're looking for this:
var f = File(mediaFolder.parent + "/" + mediaNumber.substr(0, 8) + ".html");
Copy link to clipboard
Copied
Thanks! just took out the .parent and works exactly like I wanted!
var f = File(mediaFolder + "/" + mediaNumber.substr(0, 8) + ".html");
Thank you yet again Silly-V‌
Find more inspiration, events, and resources on the new Adobe Community
Explore Now