Page 1 of 1

Breaking a Large Nissus Document into Separate Documents

Posted: 2007-09-03 12:06:43
by samuelmuindi
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

Posted: 2007-09-04 14:24:04
by martin
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?


Posted: 2007-09-17 11:58:01
by samuelmuindi
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.

Posted: 2007-09-17 16:45:09
by martin
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: Select all

$docPartPrefix = '•'

# gather start information
$filePath = Document Property ‘File Path’
If '' == $filePath
	Prompt 'The document must be saved before it can be split.'
$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."
		$docLim += 1
		Set Selection $docLim, 0
	$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';
	# 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."
	$partStart = $foundStart
	$partStart += 1 # do not include the break
	$partCount += 1

Error Message

Posted: 2007-09-18 12:14:30
by samuelmuindi
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+".


Posted: 2007-09-18 13:28:09
by martin
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: Select all

Begin Perl 
	$partPath =~ s/(\.[a-z0-9]{3,4})?$//i; 
	$partPath .= ' - part ' . ($partCount + 1) . '.rtf'; 
Sorry for the extra work- next time I will just post a link to a macro file which does not have this issue.

Same Error Message

Posted: 2007-09-18 14:24:52
by samuelmuindi
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.


Posted: 2007-09-18 14:32:24
by martin
Here's the macro saved as a Nisus Writer Macro file. Running it in NWP 1.0.1 I have no trouble.


Posted: 2007-09-19 09:30:13
by samuelmuindi
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.

Posted: 2007-09-19 10:50:56
by scottwhitlock
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.



Posted: 2007-09-19 11:39:02
by samuelmuindi
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.