Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
Hi Fredr,
Below link helpful to you.
Re: Rename the style names -- Batch
Thanks,
Prabu G
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
Hello Oriup! Thanks a lot for your help. It works really good. Best regards, Fredrik
Link in Zwischenablage kopieren
Kopiert
If it work really good, then you should mark it correct answer.
Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
I will do it tomorrow.
Sumit
Link in Zwischenablage kopieren
Kopiert
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
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen