Copy link to clipboard
Copied
Hello experts!
I'm looking for a script that can rename exisiting styles and grab the information font name, size and color and put that it in the style name.
Something like: Helvetica-16-black
And if it is possible also create new styles for the paragraphs that don't have an style.
I'm new to scripting, and is this an easy task, or is is a complicated one?
Thanks in advance!
Best regards, Fred
If it work really good, then you should mark it correct answer.
Copy link to clipboard
Copied
Hi Fredr,
Below link helpful to you.
Re: Rename the style names -- Batch
Thanks,
Prabu G
Copy link to clipboard
Copied
Hi! Thanks for the link. I think that can solve som of the problems. Is it possible in some way to rename a font with the information that style is containing. Like the new name is name: Helvetica_regular_16px_black Thanks! Best regards, Fredrik
Copy link to clipboard
Copied
Hi Fredr,
I have created batch script for you.
var myFolder = Folder.selectDialog ('Select folder with InDesing files...');
if(myFolder != null){
batch_process ();
alert("Done!");
}
function batch_process () {
var myFileList = myFolder.getFiles();
for(var f=0; f<myFileList.length; f++){
var myFile = myFileList
; if(myFile instanceof File && myFile.name.match(/.indd$/i)){
var myDocument = app.open(myFile);
rename_pStyle (myDocument);
}
}
}
function rename_pStyle (myDocument) {
var pStyles = myDocument.paragraphStyles;
for(var i=2; i<pStyles.length; i++){
var pStyle = pStyles;
var pStyleFont = (pStyle.appliedFont.name).split("\t");
var pStyleSwatch = pStyle.fillColor.name;
var pStylePointSize = pStyle.pointSize;
var pStyleName = pStyleFont[0] + "_" + pStyleFont[1] + "_" + pStylePointSize + "px_" + pStyleSwatch;
if(!myDocument.paragraphStyles.item(pStyleName).isValid){
pStyle.name = pStyleName;
}
}
}
Thanks,
Sumit
Copy link to clipboard
Copied
Hello Oriup! Thanks a lot for your help. It works really good. Best regards, Fredrik
Copy link to clipboard
Copied
If it work really good, then you should mark it correct answer.
Copy link to clipboard
Copied
Hi Oriup!
if you want to use this script on the active document, instead of a folder/batch.
How do you do then, if you can at all?
Thanks in advance!
Best regards, Fred
Copy link to clipboard
Copied
I will do it tomorrow.
Sumit
Copy link to clipboard
Copied
Please use for opened document.
if(app.documents.length > 0){
var myDocument = app.documents[0];
rename_pStyle (myDocument);
alert("Done!");
}else {
alert("Please open your document first then run.");
}
function rename_pStyle (myDocument) {
var pStyles = myDocument.paragraphStyles;
for(var i=2; i<pStyles.length; i++){
var pStyle = pStyles;
var pStyleFont = (pStyle.appliedFont.name).split("\t");
var pStyleSwatch = pStyle.fillColor.name;
var pStylePointSize = pStyle.pointSize;
var pStyleName = pStyleFont[0] + "_" + pStyleFont[1] + "_" + pStylePointSize + "px_" + pStyleSwatch;
if(!myDocument.paragraphStyles.item(pStyleName).isValid){
pStyle.name = pStyleName;
}
}
}
Sumit
Find more inspiration, events, and resources on the new Adobe Community
Explore Now