Re: Q: Mass Text convert Linux-DOS?
On Fri, Mar 30, 2001 at 05:02:27PM -0600, will trillich wrote:
> On Fri, Mar 30, 2001 at 08:07:43AM +0200, Jonathan Gift wrote:
> > I have a great many text files I have to convert from Linux to DOS
> > format. I tries recode by hand once but it took hours. There has to be an
> > automatic way.
> >
> > I tried the following but it only acted on the top level of directories
> > and not the files and subdirectories below. Any help greatly
> > appreciated:
> >
> > ----- Snip -----
> >
> > for file in ~/documents; do
> > recode latin1..ibmpc $file
> > done
> >
> > ----- Snip -----
>
> this'll preserve your original files under the new names
> "*.unix", creating dos-like cr/lf line-endings in the new
> instances...
>
> perl -i.unix -pe 's:\n:\r\n:' * subdir*/*files*/*yada*
and for catching all occurrences in all subdirectories
recursively, try
find . -type f -print0 | xargs -0 perl -i.x -pe 's:\n:\r\n:'
`find` is wonderful. especially with `xargs`.
NOTE -- this adds CR before any LF, even if there's already one
there. hopefully it won't reformat your root partition. use at
your own risk. play nice with others. learn a musical instrument.
--
does a brain cell think?
will@serensoft.com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
Reply to: