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

script needs to be fixed

Participant ,
Aug 26, 2011 Aug 26, 2011

Copy link to clipboard

Copied

Hi,

I need to prepare a script that should check and log number of files in a folder.

This is to check the text objects in the document whether it contains any color text (non black text).

Problem with my script is that

     1. it wont loop trough all the files in the folder, it just check the first file and ends.

     2. if a document consist of more number of text in color it writes each times upto the length of text in color. i just want single instance of check for a single file.

#target illustrator
var inputFolder = Folder.selectDialog ("Select a folder contains '*.eps' files ")
var Loginfo = new File(inputFolder+"/ScriptLog.txt");
Loginfo.open("w", "TEXT", "????");
if (inputFolder != null){
var fileList = inputFolder.getFiles('*.eps');
for (var i = 0; i < fileList.length; i++){
    if (fileList instanceof File && fileList.hidden == false){
        var docRef = open( fileList )
        writeLog()
        app.activeDocument.close(SaveOptions.DONOTSAVECHANGES)
    }
}
}
Loginfo.close();

//This function is to check the text objects in the document whether it contains any color text (non black text).
function writeLog(a){
    var a = app.activeDocument
    if(a.textFrames.length>0){
        for (i = 0; i < a.textFrames.length; i++ ){
            var text = a.textFrames.textRange;
            var fiTxtColor = text.fillColor;
            var txtColorType = String (fiTxtColor)
            var txtColorGray = txtColorType.search ('Gray')
                if(txtColorGray != 1){
                    Loginfo.writeln("File: "+a.name+"   Text not in Black")
                }
        }
    }
}

Hope i clearly explained my need.


Help me on this Guys..!!!!

Thanks in advance..

TOPICS
Scripting

Views

650

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 27, 2011 Aug 27, 2011

#target illustrator var inputFolder = Folder.selectDialog("Select a folder contains '*.eps' files "); var Loginfo = new File(inputFolder + "/ScriptLog.txt"); Loginfo.open("w", "TEXT", "????"); if (inputFolder) {      var fileList = inputFolder.getFiles('*.eps');      for (var i = 0; i < fileList.length; i++) {           if (fileList instanceof File && fileList.hidden == false) {                var doc = app.open(fileList);                doc.textFrames.length && writeLog(doc);                doc

...

Votes

Translate

Translate
Adobe
Enthusiast ,
Aug 27, 2011 Aug 27, 2011

Copy link to clipboard

Copied

#target illustrator var inputFolder = Folder.selectDialog("Select a folder contains '*.eps' files "); var Loginfo = new File(inputFolder + "/ScriptLog.txt"); Loginfo.open("w", "TEXT", "????"); if (inputFolder) {      var fileList = inputFolder.getFiles('*.eps');      for (var i = 0; i < fileList.length; i++) {           if (fileList instanceof File && fileList.hidden == false) {                var doc = app.open(fileList);                doc.textFrames.length && writeLog(doc);                doc.close(SaveOptions.DONOTSAVECHANGES);           }      } } Loginfo.close(); //This function is to check the text objects in the document whether it contains any color text (non black text). function writeLog(a) {      var i = 0, text = a.textFrames, len = text.length;      for (; i < len; i++) {           if (String(text.textRange.fillColor).search("Gray") != 1) {                Loginfo.writeln("File: " + a.name + "   Text not in Black");                return           }      } }

But isn't a CMYKColor [0, 0, 0, 100] also Black?

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 27, 2011 Aug 27, 2011

Copy link to clipboard

Copied

LATEST

Thanks Moluapple,

Its fine..

But isn't a CMYKColor [0, 0, 0, 100] also Black?

Yes, no doubt in it..

but no prob to worry for 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