Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Script to rename styles by font, weight and size

Entdecker ,
Jan 19, 2018 Jan 19, 2018

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

THEMEN
Skripterstellung
1.6K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Engagiert , Jan 22, 2018 Jan 22, 2018

If it work really good, then you should mark it correct answer.

Übersetzen
Engagiert ,
Jan 19, 2018 Jan 19, 2018

Hi Fredr,

Below link helpful to you.

Re: Rename the style names -- Batch

Thanks,

Prabu G

Thanks,
Prabu
Design smarter, faster, and bolder with InDesign scripting.
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Jan 22, 2018 Jan 22, 2018

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

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Jan 22, 2018 Jan 22, 2018

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

-Sumit
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Jan 22, 2018 Jan 22, 2018

Hello Oriup! Thanks a lot for your help. It works really good. Best regards, Fredrik

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Jan 22, 2018 Jan 22, 2018

If it work really good, then you should mark it correct answer.

-Sumit
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Jan 26, 2018 Jan 26, 2018

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

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Jan 26, 2018 Jan 26, 2018

I will do it tomorrow.

Sumit

-Sumit
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Engagiert ,
Feb 07, 2018 Feb 07, 2018
AKTUELL

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

-Sumit
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines