Tofrodos: Convert text files to/from MSDOS/Windows/Unix (freeware)

Tofrodos is a text file conversion utility that converts ASCII and Unicode UTF-8 files between the MSDOS (or Windows) format, which traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters, and the Unix format, which usually has LF (line breaks) to end each line.

It is a useful utility to keep close when you have to convert files between MSDOS (or Windows) and Unix/Linux/BSD (and their clones and variants). It comes standard with various systems and is often found on the system as “all”, “fromdos”, “dos2unix” and “unix2dos”.

Tofrodos is licensed under the GNU General Public License version 2. The source code is provided with the Tofrodos package.

Tofrodos comes in source code form. Precompiled binaries (executables) are only provided for the Windows console (that is, run the “all.exe” and “fromdos.exe” executables in a Command Prompt window). If you are using Linux, Mac OS X, FreeBSD or any other system, you will need to compile the source code yourself. Makefiles are provided for Linux/Mac OS X/FreeBSD (same makefile) and numerous compilers under Windows/MSDOS.

Note: both

files listed here are identical: both contain the same complete source code and Windows executables (binaries).

  • Tofrodos (zip format) (approximately 110 Kb) — download this version if you’re using Windows. It contains the complete source code and documentation formatted for Windows (CR/LF line endings), as well as the Windows console executables. (Same as the compressed tar version below.)
  • Tofrodos (compressed tar format) (approximately 98 Kb) — download this version if you’re currently on Linux (or other Unix-like systems). It contains the complete source code and documentation formatted for Unix/Linux/BSD (with LF line endings), as well as Windows console executables. (Same as previous Zip version.)

Version 1.7.13 (October 28, 2013) [Hurd, NetBSD, FreeBSD kernel]

  • Added support for Hurd, NetBSD and FreeBSD kernel. As a bonus, Tofrodos is a bit more portable as it no longer relies on certain system-specific macros (namely MAXPATHLEN from sys/param.h).

  • [All Systems]

  • Error reporting has been improved for certain error conditions. [All Systems]

  • The -a option is now documented as “deprecated”. This option has never been necessary and you should not use it.

  • [All systems] Minor changes to documentation to improve clarity.

Version 1.7.12 (October 1, 2012)

  • [All Systems] Under certain error conditions, Tofrodos may not delete temporary files that it creates. This is now fixed.

  • [All Systems] Fixed another bug where an exit code of 0 is returned, instead of 1, under certain error conditions.

  • [MSDOS

  • ] Although MSDOS is not a multitasking system, and therefore should not need it, Tofrodos’ DOS port now also uses my implementation of mkstemp(). This simplifies maintenance as I will have fewer code paths to test.

  • [Windows and MSDOS] Support for compiling source code using DJGPP 2, Borland C/C++, LCC-Win32, and Digital Mars C has been removed. Use one of the other supported compilers (e.g. Open Watcom C, etc.). Alternatively, for Windows, simply use the precompiled binary included in the package.

  • [All Systems] The documentation now has information about exit codes returned by Tofrodos.

Version 1.7.11 (September 27, 2012)

  • [All Systems] Tofrodos now consistently returns an exit code of 1 when there is a failure. Previously, under certain error conditions, you could return an exit code of -1 (which is not a valid exit code for some operating systems) instead of 1.

  • [Windows] This release now includes an implementation of mkstemp() for Windows (when compiled with Open Watcom C

  • ), bringing the Windows port (Open Watcom) of all parties on par with versions for systems such as Linux and Mac OS X that provide mkstemp() in their C libraries. Hopefully, this will help those of you who run multiple instances of tophrods at the same time in the same directory.

  • [Windows]

  • Fixed a bug introduced in 1.7.9

  • where the Windows port of tofrodos always creates the temporary file in the current directory instead of the directory where the destination file is. [Mac OS X]

  • Tofrodos’ Mac OS X port now uses mkstemp() to create the temporary file the way it does on Linux. [Mac OS X

  • ] Added more information in the readme file.txt for Mac users.

  • [All systems] Improved documentation on -p and -b options.

It is best to upgrade to the current version even if you’re not using Windows or Mac OS X. This is especially the case if you redirect stdin and stdout when running tofrodos (instead of putting filenames on the command line) and test the exit code for success/error (see the first item listed above).

Version 1.7.9 (February 27, 2011)

  • [Windows, Linux, Mac OS X, Unix] The behavior of the -b (create backup file) option has been changed to be more useful on systems with support for long file names and an arbitrary number of file extensions (that is, all systems except MSDOS). Now back up “filename.ext” as “filename.ext.bak” instead of “filename.bak”.

    Note that with this release, the DOS version no longer behaves in the same way (when using the -b option) as Windows, Linux, Mac OS X, *BSD, and other versions of Unix, as DOS systems have file name limitations. At least in this way, we are not held back by the lowest common denominator (DOS), especially since few people use DOS today.

  • [All Systems] The documentation has been updated to explain the behavior of the -b option in more detail.

Upgrade to the current version. It may be just a slight behavioral change in a rarely used option that doesn’t affect the core functionality of the program, but for someone who wants to use the option, it actually makes it usable. As far as you know, no one used the option before because of their former brain-dead behavior.

Version 1.7.8 (April 7, 2008) [Mac OS X

  • ] Fixed a bug that only appears when compiling on Mac OS X. The config.h file of the distribution package was corrupted in the section included by the APPLE macros. I’m really sorry.

Version 1.7.7 (April 1, 2008) [Mac OS X] Added support for compiling tofrodos under Mac OS X. [FreeBSD] Added support for compiling tofrodos under FreeBSD. [OpenBSD]

  • Added support for compiling tofrodos under OpenBSD (untested
  • ).

  • [
  • All systems

  • ] Fixed typographical errors in the documentation (Unix man page and HTML version). Thanks to Florian Ernst, the maintainer of the Debian package that includes tofrodos.

If you are not using Mac OS X, FreeBSD, or OpenBSD, you do not need to download this version (unless you want the corrected documentation). Other than documentation fixes, there are no changes that affect the other supported operating systems.

Version 1.7.6 (March 15, 2005)

  • [All Systems] New option: -l allows you to send error messages to a log file. It is particularly convenient for systems with less powerful command-line shells that do not allow you to easily redirect stderr.
  • [All Systems] Fixed: All error and verbose messages are now sent to stderr or the error log file (if -l is given).
  • [Windows] Earlier versions of compilers such as Borland 4.X and 5.0, Watcom 10.X, and Visual C++ 6.0 no longer have makefiles. Use the latest versions; all of these compilers are now available for free through their vendors (see the Free C/C++ Compilers page), so using the latest version to compile Tofrodos shouldn’t be much of a difficulty.
  • [All systems] Other minor fixes.

If you are a maintainer of one of the Linux distributions that uses tofrodos, update your tofrodos version to the current version. If you’re an ordinary user, of course, you can also update your own installation by simply downloading the package and installing it. Instructions can be found in the file .txt readme.

Version 1.7 (November 26, 2003)

  • [Linux/Unix] Bug fix: now handles symbolic link arguments correctly. This bug only affects Unix-like systems (such as Linux, FreeBSD, OpenBSD, etc.).
  • [Linux] tofrodos now uses mkstemp() to create the temporary file to avoid a race between creating and opening the filename that can occur when using mktemp(). If you use a non-Linux system and have mkstemp(), you can take advantage of this by setting HAVE_MKSTEMP to config.h (defined by default for Linux only).
  • [Linux/Unix] “make install” is now installed in /usr/bin by default (you can still easily change this) as Linux distributions that use tofrodos seem to use this value. (It makes it easier for maintainers of those distributions.)
  • [All Systems] Made some error messages a little more informative.
  • [All Systems] The detailed mode is a bit more informative.
  • [Windows] Added support for compiling with MinGW (GNU) C Compiler on Win32 systems.
  • [All Systems] Added an HTML version of the manual page. Useful for systems that do not have a built-in function to read a “man page” (such as MSDOS and Windows).

Version 1.6 (July 1, 2002)

  • Added support for the LCC-Win32 compiler. If you already have version 1.5 and are using the provided Windows binaries, you don’t need to bother upgrading to this version.

Version 1.5 (June 19, 2002)

  • Added support for Digital Mars C++ Compiler for Windows systems
  • .

  • Minor corrections were made to the documentation.

Version 1.4 (March 16, 1999)

  • Fixed a bug where Tofrodos crashed when invoked with -b on a file in a directory other than the current directory.

Version 1.3 (October 8, 1997)

  • Added a new option (-p) to preserve file ownership and timing
  • .

  • Added support for Win32 compilation and some compilers in DOS and Windows.

Version 1.1 (April 5, 1997)

  • Fixed a bug in creating backup and temporary file names in Linux.

Version 1.0 (June 22, 1996)

  • Initial release

.

If you find a bug or feedback, please let me know. Be sure to specify that you’re referring to Tofrodos as the contact form is a general contact form for my entire site.

How to

  • Make/Create Your Own Website: The A-Z Guide for Beginners How to
  • register your own domain name

  • Tips for getting your own
  • domain
  • name

  • Which web host do you recommend? (Frequently Asked Questions)
  • Free hard drive backup and restore,

  • hard drive images, and cloning utilities
  • Free antivirus software and free online virus scanning
  • How to install and configure

  • PHP 5 to run with
  • Apache on Windows How

  • to install and configure Apache 2 on Windows
  • How to set the height of a DIV relative to a browser window (CSS
  • )

  • Free EPUB readers (eBook viewing software
  • ) How to

  • Generate Let’s Encrypt Free SSL Certificate on Your Own Computer
  • (Windows) How to insert meta tags into a web page with

  • BlueGriffon
  • How to

  • play a song (or some other audio clip)
  • from a playlist on a website

  • Two ways to view a binary file in Windows without installing anything
  • How to

  • draw a horizontal line on a webpage with Expression Web How
  • to

  • create a website
  • for free Why can’t I invent any domain I want? Is there a way to remove
  • a registrar altogether?

  • What is the difference between a domain name registrar and a web host?

How to Create/Make Your Own Website:

  • The A-Z Guide for Beginners
  • How to register your own domain name

  • – how to get your own domain name
  • What is the difference between a content management system (CMS), a blog, a web editor and an online site builder?
  • Expression Web tutorial: How to design a website with

  • Microsoft Expression Web Dreamweaver tutorial
  • : How to design a website with

  • Dreamweaver
  • CS6 How to Make a Website

  • Optimized for Mobile Devices: Responsive Design in CSS
  • BlueGriffon Tutorial: How to Design a Website

  • with BlueGriffon 3
  • How to create a blog
  • Free CD and DVD burners and backup software
  • Hard drive backup and restore,

  • Hard Drive Images and Clone Utilities

To link to this page from your

website, simply cut and paste the following code into your web page.

<a href=”https://www.thefreecountry.com/tofrodos/index.shtml” target=”_top”>Tofrodos – Convert text files to/from MSDOS/Windows/Unix (freeware)</a>

It will appear on your page as:

Tofrodos – Convert text files to/from MSDOS/Windows/Unix (freeware)