Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

Need help to combine two scripts

$
0
0

Hi,

 

I created two scripts and running 2 times for checking the files. One is for Print files and another for the web files. I tried to combine the both scripts to one script. But the combine script is working only for the print files.

 

So can any one helps to solve this. . .


The script goes here:

#target photoshop

var myPrintFolder = Folder.selectDialog ("Select Print Folder");

if(myPrintFolder!=null){

    var myFiles_Print = myPrintFolder.getFiles(/\.(tif)$/i);

    for(var fileIndex=0;fileIndex<myFiles_Print.length;fileIndex++)

    {

        var currentFile = myFiles_Print[fileIndex];

        if(currentFile instanceof File)

        {

                if(currentFile.hidden) continue;

                    var doc = app.open(currentFile);

                   

//Checks Resolution of Image                

    var docResolution = doc.resolution

        if (docResolution != 300)

        {

            alert("File Resolution is not 300dpi");

            //doc.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

        }

 

 

//Checks Document information and copyrighted Information

                        docInfoRef = doc.info;

    if(docInfoRef.copyrighted == CopyrightedType.COPYRIGHTEDWORK)

    {

    alert("image has copyrighted");

    docInfoRef.copyrighted = CopyrightedType.UNMARKED;

    }

    else{

        if(docInfoRef.copyrighted == CopyrightedType.PUBLICDOMAIN)

        {

                 alert("image has Public-Domain");

                docInfoRef.copyrighted = CopyrightedType.UNMARKED;

            }

        }      

   

//Reads Path Items count in the document

        var docPathsItems = doc.pathItems.length

          if (docPathsItems > 1)

          {

             alert(doc.name + " "  + "File has More Path Items");

             }

        

//Reads All Path  Elements

            if(doc.pathItems[0].kind != PathKind.CLIPPINGPATH)

            {

                alert(doc.name + " "  + "is not containing Clipping Path")

            }

       

            if(doc.pathItems[0].name != "Path 1")

            {

                alert(doc.name + " "  + "Path name should be Path 1");

            }

       

            if(doc.pathItems[0].name != "Path 1" && doc.pathItems[0].kind == PathKind.WORKPATH)

            {

                alert(doc.name + " "  + "Path is in WorkPath");

                doc.pathItems[0].name = "Path 1"

            }

       

//Checks color profile

            if(doc.colorProfileType == ColorProfile.NONE)

                {

                alert(doc.name + " "  + "Color profile is not correct")

                }

          

//Checks Colour Mode

       

         if (doc.mode != DocumentMode.CMYK)

         {

             alert(doc.name + " "  + "Colour mode should be CMYK");

            //doc.changeMode(ChangeMode.CMYK);

         }

    

//Checks the size of width or height less than 2.8 CM

    var x = 2.8;

     if(doc.width > doc.height)

     {

         var roundUp = Math.round (doc.width)

         //alert ("Document width is more than height" + doc.width);

        if(roundUp < x)

        {

            alert(doc.name + " "  + "The document width is less than 2.8CM's" );

         }

     }

 

if(doc.height > doc.width)

    {

        var roundUp1 = Math.round (doc.height)

        //alert ("Document height is more than width " + doc.height);

       if(roundUp1 < x)

        {

            alert(doc.name + " "  + "The document height is less than 2.8CM's" )

         }

     }

    

//Checks the file naming convension

        myDoc = doc.name;

        value = myDoc.slice(8,-4);

        if(value < 30 || value > 40)

        {

            alert("Print File naming conversion should be -30");

        }

doc.close(SaveOptions.DONOTSAVECHANGES);

}

}

}

 

 

//Ends the Print Script

 

 

var myWebFolder = Folder.selectDialog ("Select Web Folder");

 

 

if(myWebFolder!=null){

    var myFiles_Web = myWebFolder.getFiles(/\.(tif)$/i);

    for(var fileIndex1=0;fileIndex1<myFiles_Web.length;fileIndex1++)

    {

        var currentFile = myWebFolder[fileIndex1];

        if(currentFile instanceof File)

        {

                if(currentFile.hidden) continue;

                    var doc = app.open(currentFile);

                   

//Checks Document information and copyrighted Information

                        docInfoRef = doc.info;

    if(docInfoRef.copyrighted == CopyrightedType.COPYRIGHTEDWORK)

    {

    alert("image has copyrighted");

    docInfoRef.copyrighted = CopyrightedType.UNMARKED;

    }

    else{

        if(docInfoRef.copyrighted == CopyrightedType.PUBLICDOMAIN)

        {

                 alert("image has Public-Domain");

                docInfoRef.copyrighted = CopyrightedType.UNMARKED;

            }

        }    

   

//Checks Resolution of Image                

    var docResolution = doc.resolution

        if (docResolution != 300)

        {

            alert("File Resolution is not 300dpi");

            //doc.resizeImage(undefined, undefined, 300, ResampleMethod.NONE);

        }

   

//Reads Path Items count in the document

        var docPathsItems = doc.pathItems.length

          if (docPathsItems > 1)

          {

             alert(doc.name + " "  + "File has More Path Items");

             }   

   

//Reads All Path  Elements

           if(doc.pathItems[0].name != "Path 1")

            {

                alert(doc.name + " "  + "Path name should be Path 1");

            }

       

            if(doc.pathItems[0].name != "Path 1" && doc.pathItems[0].kind == PathKind.WORKPATH)

            {

                alert(doc.name + " "  + "Path is in WorkPath");

                //doc.pathItems[0].name = "Path 1"

            }

       

//Checks color profile

            if(doc.colorProfileType == ColorProfile.NONE)

                {

                alert(doc.name + " "  + "Color profile is not correct")

                }

           

//Checks Colour Mode

       

         if (doc.mode != DocumentMode.RGB)

         {

             alert(doc.name + " "  + "Colour mode should be RGB");

            //doc.changeMode(ChangeMode.RGB);

         }

    

//Checks the size of width or height less than 2.8 CM

    var x = 2.8;

     if(doc.width > doc.height)

     {

         var roundUp = Math.round (doc.width)

         //alert ("Document width is more than height" + doc.width);

        if(roundUp < x)

        {

            alert(doc.name + " "  + "The document width is less than 2.8CM's" );

         }

     }

 

if(doc.height > doc.width)

    {

        var roundUp1 = Math.round (doc.height)

        //alert ("Document height is more than width " + doc.height);

       if(roundUp1 < x)

        {

            alert(doc.name + " "  + "The document height is less than 2.8CM's" )

         }

     }

    

//Checks the file naming convension

        myDoc = doc.name;

        value = myDoc.slice(8,-4);

        if(value < 40 || value > 40)

        {

            alert("Print File naming conversion should be -40");

        }

    doc.close(SaveOptions.DONOTSAVECHANGES);

}

}

}

 

 

//Ends the Web Script

 

 

if(myPrintFolder!=null){

    var myFiles_Print = myPrintFolder.getFiles(/\.(tif)$/i);

   

if(myWebFolder!=null){

    var myFiles_Web = myWebFolder.getFiles(/\.(tif)$/i);

   

function print(){

 

 

if (myFiles_Print.length  != myFiles_Web.length)

{

    alert("Print Files is not equal" + " " + "Total images are:" + " " + myFiles_Print.length);

}

 

 

else

{

    alert("Print Files  is equal"+ " " + "Total images are:" + " " + myFiles_Print.length);

    }

}

 

 

function web(){

 

 

if (myFiles_Web.length  != myFiles_Print.length)

{

    alert("Web Files Count is not equal" + " " + "Total images are:" + " " + myFiles_Web.length);

}

 

 

else

{

    alert("Web Files Count is equal"+ " " + "Total images are:" + " " + myFiles_Web.length);

    }

}

 

 

print();

web();

    }

}

 

 

Thanks in Advance,

Suresh.


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>