1 Reply Latest reply: Aug 3, 2009 6:42 AM by Michael L Hale RSS

    Saving Problem....?

    harrypotts Community Member

      Guys. I am new when it comes to Photoshop Scripting and when I tried to use it for the first time:Adobe JavaScript file (JSX). I was having problems with the name of the file it was saving. I tried to use a 20 loops and the filename is still the save whenever the script tried to save it. So I have to edit it still and it is time consuming. Kindly help me with these one. Pls many Thanks!!!!

       

      Here is the sample of the script:

      ------------------------------------------------------------------------------------------ ---------

       

       

       

      var fileRef = File("C:/Users/amylim/Desktop/pagawa tita amy/nail art/testtry.psd")
      var docRef = app.open(fileRef)


      //x = 1;

      newTextLayer = docRef.artLayers.add()
      newTextLayer2 = docRef.artLayers.add() //parang ito ung blank na layer
      newTextLayer3= docRef.artLayers.add()
      newTextLayer4=docRef.artLayers.add()
      newTextLayer5=docRef.artLayers.add()
      newTextLayer6=docRef.artLayers.add()

      for (var x=21;x<=100;x++) {




      /*
      unangset = "90" + x
      secondset ="90" + x
      pangatlongset= "90" + x
      pangapatnaset="90" + x
      panglimangset="90" + x
      panganim ="90" + x
      */


      unangset = "9" + x
      secondset ="9" + x
      pangatlongset= "9" + x
      pangapatnaset="9" + x
      panglimangset="9" + x
      panganim ="9" + x







      //use the kind property of the artLayer class to make the layer a text layer

      newTextLayer.kind = LayerKind.TEXT
      newTextLayer.textItem.contents = unangset //ito ung unang 90
      newTextLayer.textItem.position = Array(2.240, 0.130)
      newTextLayer.textItem.size = 9.36






      //pangalawa to
      newTextLayer2.kind = LayerKind.TEXT //nagdeclare ako ng bago layer na text
      newTextLayer2.textItem.contents = secondset //ito ung unang 90
      newTextLayer2.textItem.position = Array(2.240, 0.885)
      newTextLayer2.textItem.size = 9.36

      //end ng panglawa

      //pangatlo

      newTextLayer3.kind = LayerKind.TEXT //nagdeclare ako ng bago layer na text
      newTextLayer3.textItem.contents = pangatlongset //ito ung unang 90
      newTextLayer3.textItem.position = Array(2.24, 1.60)
      newTextLayer3.textItem.size = 9.36

      //end ng pangatlo


      //pangapat

      newTextLayer4.kind = LayerKind.TEXT //nagdeclare ako ng bago layer na text
      newTextLayer4.textItem.contents = pangapatnaset //ito ung unang 90
      newTextLayer4.textItem.position = Array(1.00, 0.130)
      newTextLayer4.textItem.size = 9.36


      //eng ng pangapat


      //panglima
      newTextLayer5.kind = LayerKind.TEXT //nagdeclare ako ng bago layer na text
      newTextLayer5.textItem.contents = panglimangset //ito ung unang 90
      newTextLayer5.textItem.position = Array(1.00, 0.885)
      newTextLayer5.textItem.size = 9.36

      //eng ng panglima

      //panganim
      newTextLayer6.kind = LayerKind.TEXT //nagdeclare ako ng bago layer na text
      newTextLayer6.textItem.contents = panganim //ito ung unang 90
      newTextLayer6.textItem.position = Array(1.00, 1.60)
      newTextLayer6.textItem.size = 9.36


      //eng ng panganim







      //jpgFile = new File( "/Testry" + x +".jpg")
      jpgSaveOptions = new JPEGSaveOptions("/Testry" + x +".jpg")
      jpgSaveOptions.embedColorProfile = true
      jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE
      jpgSaveOptions.matte = MatteType.NONE
      jpgSaveOptions.quality = 12



      docRef.saveAs(new File(jpgSaveOptions),jpgSaveOptions)




      //jpgSaveOptions.close()




      }



        • 1. Re: Saving Problem....?
          Michael L Hale Community Member

          //jpgFile = new File( "/Testry" + x +".jpg") should be something like jpgFile = new File( "/c/temp/Testry" + x +".jpg")

           

          and docRef.saveAs(new File(jpgSaveOptions),jpgSaveOptions) should then be docRef.saveAs( jpgFile, jpgSaveOptions, true );

           

          Also you do not need to close the file. If you want to close the doc you use docRef.close(SaveOptions.DONOTSAVECHANGES)