Here is a simple script in perl that is a stripped down version of a script I have used on a number of occaisions. It makes no changes before the \begin{document} line and then replaces $$ by alternately \[ and \] placed on lines of their own.
#! /usr/bin/env perl
use warnings;
use strict;
my $indoc = 0;
my $indisplaymath = 0;
my @dsubs;
$dsubs[0] = '\\[';
$dsubs[1] = '\\]';
while (<>) {
if (/\\begin{document}/) {
$indoc = 1;
}
if ($indoc == 1) {
while (/\s*\${2}\s*/p) {
my $pre = '';
my $post = '';
if (${^PREMATCH} ne '') { $pre = "\n"; }
$_ =~ s/\s*\${2}\s*/$pre$dsubs[$indisplaymath]\n/;
$indisplaymath = 1 - $indisplaymath;
}
}
print;
}
Save this as a script e.g. latexdisp.pl, give it execute permissions with chmod +x latexdisp.pl and run as latexdisp.pl file.tex >out.tex. Finally, double check the output.
For example on
\documentclass[12pt]{article}
\begin{document}
Test
$$ x = \int_0^3 y(t)\, dt $$ testing
$ p/q $
$$
e = t
$$
\end{document}
the output is
\documentclass[12pt]{article}
\begin{document}
Test
\[
x = \int_0^3 y(t)\, dt
\]
testing
$ p/q $
\[
e = t
\]
\end{document}
Modifying the strings in the $dsubs[0] and $dsubs[1] you could change the replacement to get e.g. \begin / \end{equation*} pairs. Remeber to quote the backslashes.
$$and replace odd ones with\[and even ones with\](hoping you never used the dirty$$to create an empty object). – T. Verron Nov 25 '12 at 11:08