Skip to main content
Participant
May 21, 2019
Question

Illustrator exportFile() script method replacing filename space with hyphen ("-")

  • May 21, 2019
  • 2 replies
  • 1843 views

Hi All,

Using my script,When i am trying to  export in illustrator to png with name "My ILST File.png" it is saving as "My-ILST-File.png".

I wanted names with spaces.I don't want to use this file for html.So I think space will not create a problem and I am using exportOptions.saveAsHtml as false(default). so could anyone help me in this.my code is given below

      var exportOptions = new ExportOptionsPNG24();

       exportOptions.artBoardClipping = true;          

       var fileSpec = new File("c:\\My ILST File"+".png");   

       app.activeDocument.exportFile( fileSpec, ExportType.PNG24, exportOptions );

Thanks.

This topic has been closed for replies.

2 replies

renél80416020
Inspiring
May 21, 2019

Bonjour,

Remplacer les espaces par "_"

et renommer le fichier.

var exportOptions = new ExportOptionsPNG24();

      exportOptions.artBoardClipping = true;         

      var fileSpec = new File("c:\\My_ ILST_File"+".png");   

      app.activeDocument.exportFile( fileSpec, ExportType.PNG24, exportOptions );

          fileSpec.rename("My  ILST File.png");

de elleere

Tu peux aussi utiliser c:/My_ ILST_File"+".png"); 

Inspiring
May 21, 2019

Hello,

This is a bug in Illustrator whenever there is a space in the file name. It will replace space with the hypen(-) when exporting as png.

You can use the workaround for this

var exportOptions = new ExportOptionsPNG24();

     exportOptions.artBoardClipping = true;         

     var fileSpec = new File("c:\\My ILST File"+".png");  

     app.activeDocument.exportFile( fileSpec, ExportType.PNG24, exportOptions );

     fileSpec.rename('My ILST File.png');

Rename method will allow you to keep the file name as desired.

renél80416020
Inspiring
May 21, 2019

bonjour charur94718007

Je crois que l'on s'est croisés...

Inspiring
May 21, 2019

Yes, maybe for some reason