• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Looking for a Page Swap Script

Community Beginner ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

Hi all -

I was wondering if anyone has come across a page swap script. Something simple that will popup a dialogue box and you can enter 2 pages to switch locations (without changing the location of any other pages). I don't really know much about scripting at all, so I wasn't sure if it was even possible but I did I find the below from a few years ago (from indiscripts):

function swapPages(p0, p1)

{

if (p0 == p1) return true;

var pages = app.activeDocument.pages;

var pg0 = pages.itemByName(''+p0); // force string argument

var pg1 = pages.itemByName(''+p1); // force string argument

if ( pg0.documentOffset > pg1.documentOffset ) return swapPages(p1,p0);

try {

  pg1.move(LocationOptions.AFTER,pg0);

  pg0.move(LocationOptions.AFTER,pages.itemByName(''+p1));

  return true;

  }

catch(ex) {return false;}

}

// usage:

swapPages(28,34);

This works great but the issue is it will only swap the 2 pages listed at the end (28 and 34). Was wondering how difficult would it be to adjust this to create a dialogue box when you run it, and choose the pages you want to swap.


Thanks in advance!

Views

570

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Employee , Apr 18, 2017 Apr 18, 2017

Hi

So you need a user input for your pages to be swapped. Please try following:

     var page1 = Number(prompt ("Enter Page1", 100));

     var page2 = Number(prompt ("Enter Page2", 100));

     swapPages(page1,page2);

This will prompt you a dialog to enter the page numbers. Also 100 is what a default value will be shown which you can change to anything.

Hope this resolves what you are trying to do.

Thanks

Votes

Translate

Translate
Adobe Employee ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

Hi

So you need a user input for your pages to be swapped. Please try following:

     var page1 = Number(prompt ("Enter Page1", 100));

     var page2 = Number(prompt ("Enter Page2", 100));

     swapPages(page1,page2);

This will prompt you a dialog to enter the page numbers. Also 100 is what a default value will be shown which you can change to anything.

Hope this resolves what you are trying to do.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

Thank you so much, that worked!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2017 Apr 23, 2017

Copy link to clipboard

Copied

LATEST

I'd recommend that opening poster read further into the comments on the indiscripts page that featured the script (Indiscripts :: Swapping and Reordering Pages ) as another scripter (Fabian the blind) had indeed written the script with a user interface rather than one prompt after another.

Despite that, I didn't know any of these 3 scripts existed (swap pages no UI, swap pages with UI, reorderpages) and they're all pretty cool!

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines