Remove CRLF line terminators using Emacs in batch mode

At the moment I cooperate with Windows users in writing a big latex file. A few of the editors are not willing to use version control. As result the ones using version control (like me) use diff to integrate the work of others. I am using Linux, like most of the team. So we don't have CRLF at the end of lines. To remove the CRLF in files originating from the Windows users, I use Emacs.

First: Check whether there are CRLF line endings.

$ file foo.tex
foo.tex: ISO-8859 English text, with very long lines, with CRLF line terminators

Yes, there are so let's remove them.

emacs -batch -no-site-file foo.tex \
--eval="(set-buffer-file-coding-system 'iso-latin-1-unix)" -f save-buffer

In this command line Emacs is called in batch mode. The -no-site-file argument prevents Emacs from loading init stuff like .emacs. After that the file is loaded and the command set-buffer-file-coding-system is evaluated with the coding-system iso-latin-1-unix. As last step we save the file.

Check if everything is okay now:

$ file foo.tex
foo.tex: ISO-8859 English text, with very long lines

Perfect.