View Single Post
Old 12-23-2009, 07:56 PM   #1
erik5000
Member
erik5000 began at the beginning.
 
Posts: 15
Karma: 12
Join Date: Nov 2009
Device: sony prs600
NCX playOrder nuisance

playOrder in the NCX file is a real nuisance. And unnecessary too: the playOrder follows directly from the order of the navPoints in the NCX file.
There may be no gaps in the playOrder: 10,20,30 etc is not allowed. It MUST be 1,2,3,4,5 etc

But anyway: I built myself a short AWK script to renumber the playOrder attributes. You can use it from the command line or from an ANT build script.
The result will be in the file "tempFile".

Here is the AWK wiki: http://en.wikipedia.org/wiki/AWK
# this AWK script corrects any mistakes in the playOrder of EPUB NCX files.
# use it in an ANT build script.
# the entire phrase playOrder="234" must be on ONE line !!

BEGIN {counter = 1 }
{

if (match($0, /playOrder="[0-9]*"/ ) )
{
repl = "playOrder=\"" counter "\""
sub(/playOrder="[0-9]*"/, repl )
counter++;
}
print $0 > "tempFile"
}

Last edited by erik5000; 12-24-2009 at 10:42 AM.
erik5000 is offline   Reply With Quote