5 Replies Latest reply on Jun 24, 2015 10:45 AM by d1g1talphyre

    Help! Again

    alisonw91924766

      I received the best help here a couple of weeks ago and I'm back with a similar question. I'm printing dog tags that are 1 x 2. Originally they had numbers in sequence that I was printing on the back, now my client has decided that they want a string of 12-14 random numbers, but they will start with 3 letters that are always the same. ex. ABC-18796426789132

      I print 60 up a time and they all need to be random, can photoshop do something like that. I copy and pasted 500 of these numbers the other day and it took all day and now I'm sure I'm on my way to carpal tunnel!!

      Can anyone offer any help

       

      Thanks

      Alison

        • 1. Re: Help! Again
          c.pfaffenbichler Level 9

          JavaScript offers pseudo-randomness which may be close enough to true randomness for the task.

          Maybe you should post over at

          Photoshop Scripting

          and explain the Layer structure and font setting, maybe post a layered file or at least a screenshot with the Layers Panel visible.

           

          Edit: Sorry, I had forgotten which exact Forum I was browsing …

          But please explain the Layer structure and font setting, maybe post a layered file or at least a screenshot with the Layers Panel visible nonetheless.

          • 2. Re: Help! Again
            c.pfaffenbichler Level 9

            What is the exact procedure you intend to use anyway?

            Create documents with the numbers and then print in one go, change the numbers in a Type Layer and print each variation immediately, …?

            • 3. Re: Help! Again
              d1g1talphyre Level 1

              So, to come up with the string is pretty easy.  You get 16 digits from what I'm going to show you.   

               

              myString = Math.random().toString().replace(/\./, '').slice(0,12);  (the second value in the replace method is actually two single quotes to denote a nothing value, not double quotes.)

               

              So, the Math.random() pumps out a random string of numbers between 0 and 1.

              Now we are going to change it into a string with the toString method.

              Then replace the decimal point to remove it form the string with the replace method.  Not sure if you want to check for a string starting with zero's or not.  Not sure how the random numbers need to be formatted. Then we will take off the extra characters with the slice method. 

               

              Hope this helps, enjoy!

              • 4. Re: Help! Again
                c.pfaffenbichler Level 9

                You may have overlooked that Math.random can result in "shorter" numbers (if the last couple ones would be 0), so it may be necessary to "fill them up" on occasion.

                • 5. Re: Help! Again
                  d1g1talphyre Level 1

                  good call c.pfaffenbichler.  Thank you for pointing that out.

                   

                  okay, redo that line.  Okay, ran this in a for loop 200,000 times, it always generates a 12 digit number

                   

                  number = Math.floor(Math.random()*900000000000) + 100000000000;