Skip to main content
Inspiring
August 30, 2011
Answered

remove [convert] in filename (VBscript)

  • August 30, 2011
  • 1 reply
  • 2651 views

Hello,

I rewrote a JS code in VB. Everthing works fine except the red lines.

I open an eps-file, the script resaves the file as AI (remove the [converted]) and place the file in the same directory as the original eps-file.

A single file with a correct path (eg c:\test.eps -> c:\test.ai) works fine.

Set appRef = CreateObject("Illustrator.Application")
'new inserted
var doc=appRef.ActiveDocument
var destFile = appRef.Documents.add(decodeURI(doc.fullName).replace(/(?: \[Converted\])?\.eps$/, '.ai'))   'also remove "[Converted]" from filename

Set saveOptions = CreateObject("Illustrator.IllustratorSaveOptions")
saveOptions.Compatibility = 15 'Illustrator CS5
saveOptions.EmbedICCProfile=true 'embed ICCprofile
saveOptions.Compressed=true
saveOptions.PDFCompatible=true 'pdf output

appRef.Documents(1).SaveAs (destFile), saveOptions
appRef.Documents(1).Close 2
Set appRef = Nothing

I hope someone can help me

This topic has been closed for replies.
Correct answer moluapple

Yes, that means you shouldn't run it through menu, you can just double click the vbs file to launch it.

1 reply

Inspiring
August 31, 2011

Aha, get it work. And for you another post, I add the execute action part for you, so you should create a "Convert to grayscale" action in the "Default Actions" set.

Set appRef = CreateObject("Illustrator.Application") appRef.DoScript "Convert to grayscale", "Default Actions" 'WHILE(appRef.ActionIsRunning) WScript.sleep 5000 'WEND Set saveOptions = CreateObject("Illustrator.IllustratorSaveOptions") saveOptions.Compatibility = 15 'Illustrator CS5 saveOptions.EmbedICCProfile=true 'embed ICCprofile saveOptions.Compressed=true saveOptions.PDFCompatible=true 'pdf output appRef.Documents(1).SaveAs(appRef.DoJavaScript("decodeURI(app.activeDocument.fullName).replace(/(?: \[Converted\])?\.eps$/, '.ai');")), saveOptions appRef.Documents(1).Close 2 Set appRef = Nothing

Inspiring
August 31, 2011

Great about the calling procedure for "saving"!

1 problem: the doscript doesn't work.

I created an action: test in default actions, I runned the vbs-script by File>script>other script>open the vbs-script and then I get an error:

"The do script command cannot be executed from the scripts menu"

I read in the reference guide:

Plays an action from the Actions palette.

Note:

Use DoScript only if you intend to run your script from an application external to Illustrator, such as the Windows® Script Host.

Calling DoScript when running a script from Illustrator’s File > Scripts menu may yield unexpected results.

Other suggestions to solve this problem?

moluappleCorrect answer
Inspiring
August 31, 2011

Yes, that means you shouldn't run it through menu, you can just double click the vbs file to launch it.