nisus.com
https://www.nisus.com/forum/

Breaking a Large Nissus Document into Separate Documents
https://www.nisus.com/forum/viewtopic.php?f=8&t=2533
Page 1 of 1

Author:  samuelmuindi [ 2007-09-03 12:06:43 ]
Post subject:  Breaking a Large Nissus Document into Separate Documents

I have a very large Nissus document that I would like to break up into smaller files based on manual line breaks. In other words, this very big document has sections delineated by these inserted line breaks. The sections are also marked with an "•".

So ideally I would like find a way to have Nissus find each "line break command + •" and then export the text between that marker and the next "line break command + •" into a new Nissus document.

Is this possible?

Many thanks

Author:  martin [ 2007-09-04 14:24:04 ]
Post subject: 

In Nisus Writer Express you'll need to do the work manually, eg: use a search expression to find these breaks, copy-paste the content to a new file, and save it yourself.

In Nisus Writer Pro it would be possible to create a macro to do the work for you I think. I'd need to know exactly what you mean when you say "manual line breaks". Are these page breaks, newlines, or soft returns?

Author:  samuelmuindi [ 2007-09-17 11:58:01 ]
Post subject:  Reply

I'm using Nisus Writer Express, but I would gladly buy a copy of Nisus Writer Pro to avoid having to do this work manually.

By "manual line breaks" a do mean "page breaks."

Thanks so much.

Author:  martin [ 2007-09-17 16:45:09 ]
Post subject: 

The following macro should do what you want. If your file was saved as "file.rtf" then it will create "file - part 1.rtf", "file - part 2.rtf", etc. You should be warned that the macro will overwrite these "part N" files if they already exist, so be careful.

Code:
$docPartPrefix = '•'

# gather start information
$filePath = Document Property ‘File Path’
If '' == $filePath
   Prompt 'The document must be saved before it can be split.'
   exit
End
$partCount = 0
$partStart = 1
Set Selection 1, 0 # Move to the start of the document

# We split on every break followed by a bullet character
While true
   # find the next break
   $isFound = Find "\\x0C$docPartPrefix", ‘E-W’
   If false == $isFound
      # still want to save the last document part, if not already done
      $docLim = Selected Storage Length
      If $partStart >= $docLim
         exit "Successfully split and saved the document to $partCount separate files."
      End
      $docLim += 1
      Set Selection $docLim, 0
   End
   $foundStart = Selection Location
   $foundLength = Selection Length
   
   # extract the document part
   $partLen = $foundStart
   $partLen -= $partStart
   Set Selection $partStart, $partLen
   $partContent = Read Selection
   Set Selection $foundStart, $foundLength
   
   # construct the part's file name
   $partPath = $filePath
   Begin Perl
      $partPath =~ s/(\.[a-z0-9]{3,4})?$//i;
      $partPath .= ' - part ' . ($partCount + 1) . '.rtf';
   End
   
   # save the part to another file
   $partRTF = Encode RTF $partContent
   $isWritten = Write to File $partRTF, $partPath
   If false == $isWritten
      die "Could not write the document part to '$partPath'. Aborting the macro."
   End
   
   $partStart = $foundStart
   $partStart += 1 # do not include the break
   $partCount += 1
End

Author:  samuelmuindi [ 2007-09-18 12:14:30 ]
Post subject:  Error Message

Thanks so much for this, but when I tried to run the Macro I got the message

There was an error on line 23 in the macro: Invalid variable name "docLim+".

Thanks

Author:  martin [ 2007-09-18 13:28:09 ]
Post subject: 

It sounds like you're trying to run the macro in NWP 1.0. This macro requires version 1.0.1. Sorry I did not mention that.

Also, as you are no doubt copy-pasting the macro text from Safari, you will need to replace the non-breaking space characters with regular spaces. Perl does not accept them. Only the following lines need modification:

Code:
Begin Perl
   $partPath =~ s/(\.[a-z0-9]{3,4})?$//i;
   $partPath .= ' - part ' . ($partCount + 1) . '.rtf';
End

Sorry for the extra work- next time I will just post a link to a macro file which does not have this issue.

Author:  samuelmuindi [ 2007-09-18 14:24:52 ]
Post subject:  Same Error Message

Sorry, I'm still getting that same error message even though I installed the most recent version NWP. I also think that I changed the code as you instructed but I confess that I'm having trouble making sure.

I really appreciate your help with this.

Thanks

Author:  martin [ 2007-09-18 14:32:24 ]
Post subject: 

Here's the macro saved as a Nisus Writer Macro file. Running it in NWP 1.0.1 I have no trouble.

Author:  samuelmuindi [ 2007-09-19 09:30:13 ]
Post subject:  Outstanding

Thanks so much, this really did the trick.

One final question. I'm a registered Nisus Express user, but NWP seems to be more geared to my needs. So at this point I'm try to decide whether to make good on my promise and buy NWP or to purchase the Nisus Express upgrade.

Any thoughts?

THanks again.

Author:  scottwhitlock [ 2007-09-19 10:50:56 ]
Post subject: 

Go for the NWPro upgrade. It will serve you better in the long run, especially if you need customized macros to do work for you. Also, if you ever need to work on long documents, its bookmarking, TOC, and indexing are indispensable. And there's nothing in Express that is not in Pro, however there is a lot in Pro that is not in Express. It's well worth the $15 difference.

Scott

Author:  samuelmuindi [ 2007-09-19 11:39:02 ]
Post subject:  Sold

You've convinced me.

For the record, I had originally tried to split this document using Word, but it choked on the size of the document (1100 single spaced pages) and crashed. NWP, on the other hand, spat out 850 separate text file documents in about 4 minutes.

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/