Breaking a Large Nissus Document into Separate Documents
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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
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
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
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?
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?
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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.
By "manual line breaks" a do mean "page breaks."
Thanks so much.
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
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.'
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
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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
There was an error on line 23 in the macro: Invalid variable name "docLim+".
Thanks
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
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:
Sorry for the extra work- next time I will just post a link to a macro file which does not have this issue.
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';
End
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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
I really appreciate your help with this.
Thanks
- martin
- Official Nisus Person
- Posts: 5228
- Joined: 2002-07-11 17:14:10
- Location: San Diego, CA
- Contact:
Here's the macro saved as a Nisus Writer Macro file. Running it in NWP 1.0.1 I have no trouble.
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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.
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.
- scottwhitlock
- Posts: 174
- Joined: 2004-10-26 07:10:40
- Location: Tucson, AZ
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
Scott
MacBook Pro 15
2.66 Ghz Core i7
8GB RAM
10.8.3
NWP 2.0.4
iPad 3
2.66 Ghz Core i7
8GB RAM
10.8.3
NWP 2.0.4
iPad 3
-
- Posts: 15
- Joined: 2005-01-18 15:38:02
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.
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.