This is a perfect example of the kind of stuff you can do in the unix shell of terminal. Save a text file somewhere handy like your desktop. I called mine test.txt. Then open terminal and cd to wherever you have the file. So for me I did

cd ~/Desktop

then use the fold command which breaks text files into fixed length lines like this:

fold -w30 -s test.txt

The -s parameter says to break lines on spaces. If you don't mind it breaking in the middle of a word you can leave that out. If you someday splurge on a 40 cell display just change the 30 to a 40. That at least gets you partway there. The shell has the idea of a pipe written as "|" where the output of one command becomes the input to the next. So we can pipe the output from fold to the input of the "pr" command which lets us insert page breaks like this:

fold -w30 -s test.txt | pr -tF -l27

the pr command normally adds headers and such to each page which we suppress with the -t option. The F option says to output real pagrebreaks rather than a bunch of extra newlines. The L parameter, as you can guess, is how many lines before a pagebreak.

To learn more about the fold or pr commands just type "man" followed by the command to get more details from the manual pages. man man tells you about the manual itself. Of course you probably want to write all this good stuff back out to a file. To do that we want to redirect the output to a file instead of the terminal. To do that we add a redirect using the ">" and then a filename to the end of the recipe like this:

fold -w30 -s test.txt | pr -tF -l27 > fixed.txt

and you should find a fixed.txt file on your desktop all nicely formatted. Welcome to the dark underbelly of OSX where great power and capability lie, if you can just find the right man page :)

CB

On 2/27/12 6:47 AM, John Sanfilippo wrote:
Oo, I have much the same concern, so I'm looking forward to hearing more about 
this.

js


On Feb 27, 2012, at 9:42 AM, Paul Erkens wrote:

Dear listers,

I have an old braille printer that is not attached to my mac. To emboss 
something, all I have to do is create simple plain text files with 27 lines per 
page, and no more than 30 characters per line. Looking at how text edit handles 
printing however, that works with inches or centimeters, and in general, with a 
bitmap, the size of the paper you choose to print on. Characters, lines and the 
whole page can be scaled.

However, what I need for my braille printer is to ignore scaling, and tell text 
edit to wrap to the next line after 30 characters max, and a page break after 
27 lines, no matter which font size etc I choose, because fonts etc are not 
important in braille.

Once a text document has been loaded in text edit, how do I reformat it, so 
that it writes a carriage return line feed pair at the end of each line of 30 
characters most, and a page break, control l, at the end of 27 lines? Very 
interested. I'm now doing it all by hand, but since I received 8 songs from my 
choir all at once, I'm hoping to learn an easier way to reformat typed text 
into something my braille printer can handle. That braille printer is on 
windows, but I'd rather do all the preparations in text edit, than on a windows 
machine. Is it possible to make text edit do what I need here?

Paul.


--
You received this message because you are subscribed to the Google Groups 
"MacVisionaries" group.
To post to this group, send email to macvisionaries@googlegroups.com.
To unsubscribe from this group, send email to 
macvisionaries+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/macvisionaries?hl=en.

Reply via email to