1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
|
@c $Id: platform-conversions.texinfo,v 1.9 2001/05/16 16:57:58 m Exp m $
@node Platform Conversions, Reminders, Printing, Productivity
@comment node-name, next, previous, up
@chapter Cross-Platform Conversions
@cindex cross-platform conversions
@cindex conversions, cross-platform
@cindex proprietary formats, converting data from
@noindent
Sometimes, it's inevitable---through no choice of your own, you must
deal with a disk from another operating system, or a file with data
stored in a proprietary format from one of these systems.
The recipes in this chapter are about converting data from other
platforms---reading disks from DOS, Windows, and MacOS systems, and
converting DOS text and Microsoft Word files.
@menu
* DOS Disks:: Dealing with DOS and Windows disks.
* Mac Disks:: Dealing with MacOS disks.
* DOS Text:: Converting text files between DOS and Linux.
* Converting Word:: Dealing with Microsoft Word files.
@end menu
@node DOS Disks, Mac Disks, Platform Conversions, Platform Conversions
@comment node-name, next, previous, up
@section Using DOS and Windows Disks
@cindex using DOS and Windows disks
@cindex DOS disk, using
@cindex Windows disk, using
@pindex mtools
@flushleft
@sf{Debian}: @file{mtools}
@sf{WWW}: @url{http://mtools.linux.lu/}
@end flushleft
@*
@noindent
The @code{mtools} package provides a collection of tools to facilitate
the manipulation of MS-DOS files. These tools allow you to use and
manipulate MS-DOS disks (usually floppies, but Jaz and Zip drives are
supported, too); they can handle the extensions to the MS-DOS format
which are used by the different Microsoft Windows operating systems,
including Windows NT.
The following recipes describe how to use some of the tools in this
package to get directory listings of MS-DOS disks, copy files to and
from them, delete files on them, and even format them. They're similar
in use and syntax to the equivalent MS-DOS commands.
@menu
* Mdir:: Listing the contents of DOS disks.
* Mcopy:: Copying files to and from DOS disks.
* Mdel:: Deleting files on DOS disks.
* Mformat:: Formatting DOS disks.
@end menu
@node Mdir, Mcopy, DOS Disks, DOS Disks
@comment node-name, next, previous, up
@subsection Listing the Contents of a DOS Disk
@cindex listing the contents of a DOS disk
@cindex DOS disk, listing the contents of a
@pindex mdir
@noindent
Use @code{mdir} to get a directory listing of a DOS disk. Give as an
argument the ``drive letter'' of the disk to read, as used by DOS; for
example, to specify the primary floppy drive, use @samp{A:} as the drive
to read, and use @samp{B:} to specify the secondary floppy drive.
@itemize @bullet
@item
To get a directory listing of the DOS disk currently in the primary
floppy drive, type:
@example
$ @kbd{mdir a: @key{RET}}
@end example
@end itemize
@node Mcopy, Mdel, Mdir, DOS Disks
@comment node-name, next, previous, up
@subsection Copying Files to and from a DOS Disk
@cindex copying files to and from a DOS disk
@cindex DOS disk, copying files to and from a
@pindex mcopy
@noindent
Use @code{mcopy} to copy files to and from a DOS disk.
To copy a file @emph{to} a DOS disk, give as arguments the name of the
source file to copy and the ``drive letter'' of the disk to copy it to.
@itemize @bullet
@item
To copy the file @file{readme.txt} to the DOS disk in the primary floppy
drive, type:
@example
$ @kbd{mcopy readme.txt a: @key{RET}}
@end example
@end itemize
To copy a file @emph{from} a DOS disk, give the ``drive letter'' of the
disk to copy from, followed by the file name to copy, and no other
arguments; @code{mcopy} will copy the specified file to the current
directory.
@itemize @bullet
@item
To copy the file @file{resume.doc} from the DOS disk in the secondary
floppy drive to the current directory, type:
@example
$ @kbd{mcopy b:resume.doc @key{RET}}
@end example
@end itemize
To copy all files from a DOS disk, just give the ``drive letter''
without any file names.
@itemize @bullet
@item
To copy all of the files and directories from the DOS disk in the
primary floppy drive to the current directory, type:
@example
$ @kbd{mcopy a: @key{RET}}
@end example
@end itemize
@node Mdel, Mformat, Mcopy, DOS Disks
@comment node-name, next, previous, up
@subsection Deleting Files on a DOS Disk
@cindex deleting files on a DOS disk
@cindex DOS disk, deleting files on a
@pindex mdel
@noindent
Use @code{mdel} to delete a file on a DOS disk. Give as an argument the
name of the file to delete preceded by the ``drive letter'' of the disk
to delete from.
@itemize @bullet
@item
To delete the file @file{resume.doc} on the DOS disk in the primary
floppy drive, type:
@example
$ @kbd{mdel a:resume.doc @key{RET}}
@end example
@end itemize
@node Mformat, , Mdel, DOS Disks
@comment node-name, next, previous, up
@subsection Formatting a DOS Disk
@cindex formatting a DOS disk
@cindex DOS disk, formatting a
@pindex mformat
@noindent
To format a floppy disk for DOS, writing an empty MS-DOS filesystem to
the disk in the process, use @code{mformat}. Give as an argument the
name of the ``drive letter'' of the disk to format. (Remember, when you
format a disk, any existing information contained on the disk is lost.)
@itemize @bullet
@item
To format the floppy disk in the primary floppy drive so that it can be
used with MS-DOS, type:
@example
$ @kbd{mformat a: @key{RET}}
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} If you want to use a floppy disk with your Linux system
and don't need DOS compatibility, don't bother using this MS-DOS
format---the native Linux format is much more efficient
(@pxref{Formatting Floppies, , Formatting a Floppy Disk}). If you know
how long a DOS format takes, you'll be amazed at how much faster the
Linux format is, too---it will do it so fast you'll think it didn't
work!
@node Mac Disks, DOS Text, DOS Disks, Platform Conversions
@comment node-name, next, previous, up
@section Using Macintosh Disks
@cindex using Macintosh disks
@cindex Macintosh disk, using
@cindex Hierarchical File System (HFS)
@pindex hfsutils
@flushleft
@sf{Debian}: @file{hfsutils}
@sf{WWW}: @url{http://www.mars.org/home/rob/proj/hfs/}
@end flushleft
@*
@noindent
Apple Macintosh computers use a file system called the ``Hierarchical
File System,'' or HFS. The @code{hfsutils} package contains a set of
tools to read and write disks in the HFS format.
The following recipes describe the use of the individual tools in this
package.
@menu
* Hmount:: Specifying which Mac disk to use.
* Hdir:: Listing the contents of a Mac disk.
* Hcopy:: Copying files to and from Mac disks.
* Hdel:: Deleting files on a Mac disk.
* Hformat:: Formatting a Mac disk.
@end menu
@node Hmount, Hdir, Mac Disks, Mac Disks
@comment node-name, next, previous, up
@subsection Specifying the Macintosh Disk to Use
@cindex specifying the Macintosh disk to use
@cindex Macintosh disk, specifying
@pindex hmount
@noindent
To use a Macintosh disk with any of the @file{hfsutils} commands, you
must first use @code{hmount} to specify the location of the HFS
filesystem. Give as an argument the name of the Linux device file where
the HFS filesystem exists; this virtually ``mounts'' the disk for use
with the other @file{hfsutils} described in this section.
The device file for the first floppy drive is @file{/dev/fd0}, and for
the second drive, @file{/dev/fd1}. Any valid device name, such as a
SCSI device or Zip disk, may be given.
@itemize @bullet
@item
To introduce the floppy disk in the first floppy drive as an HFS volume
for the @file{hfsutils}, type:
@example
$ @kbd{hmount /dev/fd0 @key{RET}}
@end example
@end itemize
After you run this command, the other tools in the @code{hfsutils}
package will work on the Macintosh disk in the first floppy drive.
@node Hdir, Hcopy, Hmount, Mac Disks
@comment node-name, next, previous, up
@subsection Listing the Contents of a Macintosh Disk
@cindex listing the contents of a Macintosh disk
@cindex Macintosh disk, listing the contents of a
@pindex hls
@pindex hmount
@noindent
Use @code{hls} to get a directory listing of the Macintosh disk
currently specified with @code{hmount} (@pxref{Hmount, , Specifying the
Macintosh Disk to Use}).
@itemize @bullet
@item
To get a directory listing of the currently specified Macintosh disk,
type:
@example
$ @kbd{hls @key{RET}}
@end example
@end itemize
Give the name of a directory as a quoted argument.
@itemize @bullet
@item
To get a directory listing of the @file{Desktop Folder} directory in the
currently specified Macintosh disk, type:
@example
$ @kbd{hls 'Desktop Folder' @key{RET}}
@end example
@end itemize
@node Hcopy, Hdel, Hdir, Mac Disks
@comment node-name, next, previous, up
@subsection Copying Files to and from a Macintosh Disk
@cindex copying files to and from a Macintosh disk
@cindex Macintosh disk, copying files to and from a
@pindex hcopy
@pindex hmount
@noindent
Use @code{hcopy} to copy files to and from the Macintosh disk currently
specified with @code{hmount} (@pxref{Hmount, , Specifying the Macintosh
Disk to Use}).
To copy a file @emph{to} a Mac disk, give as arguments the name of the
source file to copy and the quoted name of the target directory on the
Mac disk.
@itemize @bullet
@item
To copy the file @file{readme.txt} to the @samp{Desktop Folder}
directory in the current Mac disk, type:
@example
$ @kbd{hcopy readme.txt 'Desktop Folder' @key{RET}}
@end example
@end itemize
To copy a file @emph{from} a Mac disk, give the name of the directory
and file to copy as a quoted argument, and the name of the target
directory to copy to.
@itemize @bullet
@item
To copy the file @file{Desktop Folder:Readme} from the current Mac
disk to the current directory, type:
@example
$ @kbd{hcopy 'Desktop Folder:Readme' . @key{RET}}
@end example
@end itemize
@node Hdel, Hformat, Hcopy, Mac Disks
@comment node-name, next, previous, up
@subsection Deleting Files on a Macintosh Disk
@cindex deleting files on a Macintosh disk
@cindex Macintosh disk, deleting files on a
@pindex hdel
@pindex hmount
@noindent
Use @code{hdel} to delete a file on the Macintosh disk currently
specified with @code{hmount} (@pxref{Hmount, , Specifying the Macintosh
Disk to Use}). Give as a quoted argument the path name of the file to
delete. It deletes both the resource fork and the data fork of the files
you specify.
@itemize @bullet
@item
To delete the file @file{Desktop Folder:Readme} on the current Mac
disk, type:
@example
$ @kbd{hdel 'Desktop Folder:Readme' @key{RET}}
@end example
@end itemize
@node Hformat, , Hdel, Mac Disks
@comment node-name, next, previous, up
@subsection Formatting a Macintosh Disk
@cindex formatting a Macintosh disk
@cindex Macintosh disk, formatting a
@pindex hformat
@noindent
To format a disk for the Mac, writing an empty HFS filesystem to the
disk, use @code{hformat}. Give as an argument the name of the Linux
device file where the disk is at; for example, the device file for the
first floppy drive is @file{/dev/fd0}, and the second drive is
@file{/dev/fd1}
@itemize @bullet
@item
To format the disk in the first floppy drive with a Macintosh HFS
filesystem, type:
@example
$ @kbd{hformat /dev/fd0 @key{RET}}
@end example
@end itemize
If the disk currently has a partition on it, this command won't work;
use the @samp{-f} option to @emph{force} the format, thus erasing any
existing partition and data the disk contains.
Give a label for the drive as a quoted argument to the @samp{-l}
option. The label name can't contain a colon character (@samp{:}).
@itemize @bullet
@item
To format the disk in the first floppy drive with a Mac HFS filesystem,
overwriting any existing Mac filesystem, type:
@example
$ @kbd{hformat -f /dev/fd0 @key{RET}}
@end example
@item
To format the disk in the second floppy drive with a Mac HFS filesystem,
giving it a volume label of @samp{Work Disk}, type:
@example
$ @kbd{hformat -l 'Work Disk' /dev/fd1 @key{RET}}
@end example
@end itemize
When a disk has multiple partitions, give the number of the partition to
format as an additional argument. To format the entire medium, give
@samp{0} as the partition to use.
@itemize @bullet
@item
To format the second partition of the SCSI disk at @file{/dev/sd2} with
a Mac HFS filesystem, type:
@example
$ @kbd{hformat /dev/sd2 2 @key{RET}}
@end example
@item
To format the @emph{entire} SCSI disk at @file{/dev/sd2} with a Mac HFS
filesystem, overwriting any existing Mac filesystem and giving it a
label of @samp{Joe's Work Disk}, type:
@example
$ @kbd{hformat -f -l "Joe's Work Disk" /dev/sd2 0 @key{RET}}
@end example
@end itemize
@node DOS Text, Converting Word, Mac Disks, Platform Conversions
@comment node-name, next, previous, up
@section Converting Text Files between DOS and Linux
@cindex converting text files between DOS and Linux
@cindex text files, converting between DOS and Linux
@cindex DOS text files, converting
@pindex todos
@pindex fromdos
@flushleft
@sf{Debian}: @file{sysutils}
@sf{WWW}: @url{http://web.singnet.com.sg/~cslheng/}
@end flushleft
@*
@noindent
In all versions of DOS (and all subsequent versions of Microsoft
Windows), text files are normally written with both a linefeed character
and a newline, both ``invisible'' control characters, to signify the end
of each line. In Linux and other unices, text files have only the
newline character.
In either of these operating systems, text files that originated from
the other may display irregularly---in DOS and Windows, the lines of a
Linux text file may appear to run together; in Linux, a DOS or Windows
text file may have @samp{^M} newline characters at the end of each line.
To convert a text file from DOS to Linux, removing the @samp{^M} newline
characters in the file, use @file{fromdos}. It converts the file you
give as an argument, removing the newline characters from the ends of
all its lines.
To convert a text file from Linux to the convention used by DOS and
Windows, use @code{todos}. It adds newline characters to the ends of all
lines in the file you give as an argument.
@itemize @bullet
@item
To remove the newline characters from the text file @file{autoexec.bat},
type:
@example
$ @kbd{fromdos autoexec.bat @key{RET}}
@end example
@item
To add newline characters to all of the text files with a @file{.tex}
extension in the current directory, type:
@example
$ @kbd{todos *.tex @key{RET}}
@end example
@end itemize
@sp .25
@noindent
@strong{NOTE:} Both commands directly write to the files you specify. To
make a backup of the original file, use the @samp{-b} option; before the
conversion, this writes a copy of each specified file with a @file{.bak}
file name extension.
@node Converting Word, , DOS Text, Platform Conversions
@comment node-name, next, previous, up
@section Converting Microsoft Word Files
@cindex converting Microsoft Word files
@cindex Microsoft Word files, converting
@cindex files, converting Microsoft Word
@pindex word2x
@flushleft
@sf{Debian}: @file{word2x}
@sf{WWW}: @url{http://word2x.alcom.co.uk/}
@end flushleft
@*
@noindent
Use @code{word2x} to convert Word 6 files to a format you can read. It
can convert files to two different formats: LaTeX and plain text.
Convert to LaTeX when the @emph{layout} of the original document,
including its formatting and font characteristics, is important. When
you just need the complete @emph{text} of the document, convert it to
plain text. @code{word2x} can send its output to the standard output, so
the latter conversion is useful for adding to a pipeline.
Word files usually have a @file{.doc} or @file{.DOC} extension, which
you don't have to specify---for example, if the Word file you want to
convert is called @file{resume.doc}, you can simply give @samp{resume}
as the source file. (But if there exists another file named
@file{resume} in the same directory, this trick won't work).
If you don't specify an output file, @code{word2x} writes its output to
a file with the same base file name and an appropriate extension for the
output format. This is useful for converting a lot of Word files in the
same directory---specifying a wildcard such as @samp{*.doc} as the input
and no output name will convert them all.
You can also set the maximum line width to be used in the output file;
specify the width as an argument to the @samp{-w} option.
The following recipes describe how to use @code{word2x} to convert Word
files to LaTeX and plain text format.
@sp .25
@noindent
@strong{NOTE:} While @code{word2x} does a pretty good job of conversion,
it won't convert any pictures embedded in Word documents.
Another way to read Word files is to import them into the AbiWord or
StarWriter word processors (@pxref{Typesetting Systems, , Other Word
Processors and Typesetting Systems}).
@menu
* Word To LaTeX:: Converting Word to LaTeX.
* Word To Text:: Converting Word to plain text.
@end menu
@node Word To LaTeX, Word To Text, Converting Word, Converting Word
@comment node-name, next, previous, up
@subsection Converting Word to LaTeX
@cindex converting Word to LaTeX
@cindex Word, converting to LaTeX
@pindex word2x
@noindent
To convert a Word file to LaTeX format, use @code{word2x} and use
@samp{latex} as an argument to the @samp{-f} option.
@itemize @bullet
@item
To convert the Word file @file{resume.doc} to LaTeX, type:
@example
$ @kbd{word2x -f latex resume.doc @key{RET}}
@end example
@end itemize
This command writes a new file, @file{resume.ltx}, in the LaTeX format;
you can then view, print, or convert the file to other formats---see
@ref{Processing LaTeX, , Processing LaTeX Files}. The original
@file{resume.doc} file is unaltered.
@itemize @bullet
@item
To convert all of the @file{.DOC} Word files in the current directory to
LaTeX files with maximum line widths of 40 characters, type:
@example
$ @kbd{word2x -f latex -w 40 *.DOC @key{RET}}
@end example
@end itemize
@node Word To Text, , Word To LaTeX, Converting Word
@comment node-name, next, previous, up
@subsection Converting Word to Plain Text
@cindex converting Word to plain text
@cindex Word, converting to plain text
@pindex word2x
@pindex grep
@noindent
To convert a Word file to plain text, use @code{word2x}, and use
@samp{text} as an argument to the @samp{-format} option.
@itemize @bullet
@item
To convert the Word file @file{resume.doc} to a plain text file called
@file{resume}, type:
@example
$ @kbd{word2x -f text resume.doc resume @key{RET}}
@end example
@end itemize
To send a conversion to the standard output, give a hyphen character,
@samp{-}, as the output file to use. This is useful for piping the plain
text conversion to other tools that work on text, such as @code{grep}, a
tool for searching text (@pxref{Word Search, , Searching for a Word or
Phrase}).
@itemize @bullet
@item
To search the text of the Word file @file{resume.doc} for the string
@samp{linux} regardless of case, type:
@example
$ @kbd{word2x resume.doc - | grep -i linux @key{RET}}
@end example
@end itemize
These commands convert the Word file @file{resume.doc} to text, and
output all lines of that text, if any, that contain the string
@samp{linux} regardless of case. The original @file{resume.doc} file is
unaltered.
|