• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

remove [convert] in filename (VBscript)

Participant ,
Aug 30, 2011 Aug 30, 2011

Copy link to clipboard

Copied

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

TOPICS
Scripting

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Aug 31, 2011 Aug 31, 2011

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

Votes

Translate

Translate
Adobe
Enthusiast ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

Not script advise but a general comment… [Converted] is a switchable app pref…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 31, 2011 Aug 31, 2011

Copy link to clipboard

Copied

That's the solution!

Thanks

Now, a new job for adobe: rewrite the manual in "newbie" language.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Sep 01, 2011 Sep 01, 2011

Copy link to clipboard

Copied

LATEST

If they do then I will consider myself for the download…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines