6 Replies Latest reply on Oct 4, 2017 7:22 AM by Test Screen Name

    Randomize pdf pages

    jasonp10 Level 1

      Hello all, thanks for taking the time to read this. Not sure if this is the most appropriate forum. I use notecards to study that I type in word and save as pdfs. They are all laid out the same: the odd numbered pages are the front and the next even page is the back. Is there a way to randomize a pdf document so that I can shuffle the deck, so to speak, such that it is always odd then odd+1?

       

      If you are interested, I can send you a sample pdf of my notecards, I must have close to 10,000 of them from medical school through residency, but the lack of being able to shuffle them really does hinder studying a bit. I would definitely be willing barter for your help. Message me back and we can exchange emails. Thanks,

       

      -jason

        • 1. Re: Randomize pdf pages
          try67 MVP & Adobe Community Professional

          It's maybe not the best code in the world, but it should get the job done. Run it from the Console window, or attach it to a button to have easy access to it:

           

          for (var p=0; p<this.numPages; p++) {
              this.movePage(p, Math.floor(Math.random()*(this.numPages-1)));
          }
          
          • 2. Re: Randomize pdf pages
            jasonp10 Level 1

            Thanks for the quick reply! I'll let you know how it works.

            • 3. Re: Randomize pdf pages
              benh93016770 Level 1

              Did you get it to work?

              • 4. Re: Randomize pdf pages
                Test Screen Name Most Valuable Participant

                Looks good to me. Did you try it benh?

                • 5. Re: Randomize pdf pages
                  benh93016770 Level 1

                  I didn't end up using this piece of code, no, as I was unfamiliar with the Console.

                   

                  If you’d like my DIRTY solution, here it is:

                   

                  I had a 330-page PDF to split and randomize.

                   

                  In Automator, I used a Finder action. You can build it yourself by searching under “Actions” for “Ask for Finder Items” (drag this into the first position), and “Split PDF” (drag this into the second position).

                  split-automator.gif

                  Run this script on the PDF you need to split. It will save as single pages.

                   

                  Then open Apple Script Editor, paste this into the script editor window:

                   

                  tell application "Finder"

                    repeat with this_item in (get items of window 1)

                    set name of this_item to ((random number from 1000 to 5000) & "." & name extension of this_item) as string

                    end repeat

                  end tell

                   

                  Before you run this script - copy all of your single-page PDFs to a secure location for back up.

                   

                  Then ensure all Finder windows are closed (the script changes filenames on ANY FILE IN THE TOP FINDER WINDOW! Do not run this script on your Applications folder.

                   

                  Open the Finder window with the single-page PDFs inside and press the RUN key. The script will change some filenames, then probably crash and say “There is a duplicate filename”. :\

                   

                  At this point, scoop all the renamed PDFs into a KEEP folder and press run again, and again, and again, until all the PDFs are renamed. Careful to hit the “Keep Both” button when the Finder asks of you want to replace files as you move them.

                  • 6. Re: Randomize pdf pages
                    Test Screen Name Most Valuable Participant

                    Thanks for sharing that. Looks like a lot more work though. The console is in Acrobat Pro, search tools in Acrobat Pro DC for JavaScript.