1 Reply Latest reply on Aug 24, 2011 1:04 PM by Nictra_Savios

    Text Layers via Text File (ExtendScript)

    Nictra_Savios Level 1

      It keeps saying Im posting a blank message when I paste my details in..... (grr!)


      So here it is: on pastebin....  http://pastebin.com/EE7wthQ5


      Ill fix it if i can....

        • 1. Re: Text Layers via Text File (ExtendScript)
          Nictra_Savios Level 1
          I am totally new at this extendscript stuff, but it will be my 6th coding/scripting language if I can become profficiant in it (This is bassicly Javascript right?). ( after C++, Objective-C, AppleScript, AutoHotKey and Bash... I don't count HTML/CSS)
          So this is script number zero, I need somewhere to start, and I have a project I've been working on that I can't see another way to do it, so since I'm new at this, id like you to help me write this, I honestly have no idea, not even a clue where to start (Time for 'hello world!' eh?).
          Anyway, what I would like help making is a script, that will take the 50 text files I have in a folder [ D:\Code\Examples\HelloWorld\*.txt] and make them all text layers with font: Anonymous Pro, Size 8, Color 0xFFFFFF. Alighted to the top/left at 0,0. I would like the layer name to be the Text-files name before the last period (I say last because one is named Visual Basic .NET.txt)... although first wouldn't be too bad. (So lets just say, until a period)
          The reason I can't do this task by hand is simple, they are all 'Hello World' Examples, they are in 49 different coding languages. Each language has a seperate text file, like Bash.txt, Ada.txt, (Extendscript.txt next? .. make it an even 50 XD)
          So, little help making this? Maybe an example?
          Here is what I have so far (Horrible Code... I know ):
          var docRef = app.documents.add()
          var artLayerRef = app.ActiveDocument.artLayers.add()
          var fileArray = new Array()
              fileArray[1] = "Ada"
          fileArray[2] = "Assembler (gcc)"
          fileArray[3] = "Assembler (nasm)"
          fileArray[4] = "AutoHotKey"
          fileArray[5] = "AWK"
          fileArray[6] = "Bash"
          fileArray[7] = "bc"
          fileArray[8] = "C"
          fileArray[9] = "C#"
          fileArray[10] = "C++"
          fileArray[11] = "C99"
          fileArray[12] = "CLIPS"
          fileArray[13] = "Clojure"
          fileArray[14] = "COBOL"
          fileArray[15] = "COBOL 85"
          fileArray[16] = "D"
          fileArray[17] = "Erlang"
          fileArray[18] = "F#"
          fileArray[19] = "Factor"
          fileArray[20] = "Falcon"
          fileArray[21] = "Forth"
          fileArray[22] = "Fortran"
          fileArray[23] = "Go"
          fileArray[24] = "Groovy"
          fileArray[25] = "Haskell"
          fileArray[26] = "Icon"
          fileArray[27] = "Java"
          fileArray[28] = "JavaScript"
          fileArray[29] = "List"
          fileArray[30] = "Lua"
          fileArray[31] = "Nemerle"
          fileArray[32] = "Nice"
          fileArray[33] = "Nimrod"
          fileArray[34] = "Ocaml"
          fileArray[35] = "Oz"
          fileArray[36] = "Pascal"
          fileArray[37] = "Perl"
          fileArray[38] = "PHP"
          fileArray[39] = "Pike"
          fileArray[40] = "Prolog (gnu)"
          fileArray[41] = "Prolog (swi)"
          fileArray[42] = "Python"
          fileArray[43] = "Python 3"
          fileArray[44] = "Ruby"
          fileArray[45] = "Scala"
          fileArray[46] = "Scheme (guile)"
          fileArray[47] = "Smalltalk"
          fileArray[48] = "Tcl"
          fileArray[49] = "Visual Basic" 
          var countDown = 49
          for ( count = 1; count > countDown; count++)
          currentName = fileArray[count]
          artLayerRef.name = currentName
          artLayerRed.blendMode = BlendMode.NORMAL
          artLayerRef.kind = LayerKind.TEXT
          var currentContents = "D:\Code\Examples" + currentName + ".txt"
          docRef.artLayers[currentName].textItem.contents = currentContents
          Yea I know its probably all wrong... thats why I need help.