Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 92406

Can you crrect my script?

$
0
0

Hi every one

 

 

I got this script:

 

//---------------------------------------------------------------------------------------- -------------------

var book = app.activeBook, 
    _content = []; 
    overlap = []; 
for(var i =book.bookContents.length-1;i>=0;i--) 

        _content.push(book.bookContents[i].name + "\t" + (book.bookContents[i].documentPageRange.replace(/-[^-]+$/g,"")) + "\r"); 
        if(book.bookContents[i].documentPageRange == book.bookContents[i-1].documentPageRange) 
        { 
                overlap.push(book.bookContents[i].name + "\t" +book.bookContents[i].documentPageRange + "\r" + book.bookContents[i-1].name + "\t" +book.bookContents[i-1].documentStartPage); 
            } 
    } 
alert(overlap.reverse())

//alert(_content);
    WriteToFile(_content, overlap);
function WriteToFile(text) {
    file = new File("~/Desktop/Book contents and page number.txt");
    file.encoding = "UTF-8";
    file.open("w");
    file.write(text);
    file.close();
    file.execute();
}
//---------------------------------------------------------------------------------------- -------------------

 

aim to get book contents report

and tell me the overlop page numbers

 

 

I got the text file:

 

======================================================

 

13 Notes to account.indd 28

,14 Corporate Information.indd 27

,12 Cash flow statement.indd 26

,11 Equity change.indd 25

,10 Profit and loss.indd 20

,09 Income statement.indd 19

,08 Auditor's report.indd 18

,07 Directors' report.indd 17

,06 CG report.indd 12

,05 MD and A.indd 7

,03 Financial highlight.indd 6

,04 Chairman's statement.indd 3

,02 Summary.indd 2

,01 Contents.indd 1

======================================================

the sequence are upside down

======================================================

 

 

 

1) it always report me, the book has overlop page number, even the book has no overlop page number

2) if the files has overlop over more 2 pages or more two files have overlop page numbers the         alert(overlap.reverse())              will not correct in report

3) the report text file has a comma at beginning of each line

4) the sequence are upside down

 

I expected the       alert(overlap.reverse())   don't show if book has not overlap page number

can you fix it?

 

Harvey


Viewing all articles
Browse latest Browse all 92406

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>