Reply to topic  [ 11 posts ] 
Breaking a Large Nissus Document into Separate Documents 
Author Message

Joined: 2005-01-18 15:38:02
Posts: 15
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


2007-09-03 12:06:43
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
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?


2007-09-04 14:24:04
Profile WWW

Joined: 2005-01-18 15:38:02
Posts: 15
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.


2007-09-17 11:58:01
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
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


2007-09-17 16:45:09
Profile WWW

Joined: 2005-01-18 15:38:02
Posts: 15
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


2007-09-18 12:14:30
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
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.


2007-09-18 13:28:09
Profile WWW

Joined: 2005-01-18 15:38:02
Posts: 15
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


2007-09-18 14:24:52
Profile
Official Nisus Person
User avatar

Joined: 2002-07-11 17:14:10
Posts: 4251
Location: San Diego, CA
Post 
Here's the macro saved as a Nisus Writer Macro file. Running it in NWP 1.0.1 I have no trouble.


2007-09-18 14:32:24
Profile WWW

Joined: 2005-01-18 15:38:02
Posts: 15
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.


2007-09-19 09:30:13
Profile
User avatar

Joined: 2004-10-26 07:10:40
Posts: 174
Location: Tucson, AZ
Post 
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

_________________
MacBook Pro 15
2.66 Ghz Core i7
8GB RAM
10.8.3
NWP 2.0.4
iPad 3


2007-09-19 10:50:56
Profile

Joined: 2005-01-18 15:38:02
Posts: 15
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.


2007-09-19 11:39:02
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software