Append .eps to included figures [duplicate]

Is there a way to define a new command so that existing

``````\includegraphics[scale=x]{fig_name}
``````

becomes

``````\includegraphics[scale=x]{fig_name.eps}
``````

for any x and fig_name? This is for automatic conversion of eps to pdf because eps may cause out of memeory issues with xdvipdfmx: xdvipdfmx out of memory.

-

marked as duplicate by Werner, Claudio Fiandrino, Thorsten, Jesse, ChrisSApr 3 '14 at 7:02

If all your usages exclude the use of a file extension, then you can simply do

``````\usepackage{graphicx,letltxmacro}
\LetLtxMacro{\oldincludegraphics}{\includegraphics}
\renewcommand{\includegraphics}[2][]{\oldincludegraphics[#1]{#2.eps}}
``````

which would transform

``````\includegraphics[*]{**}
``````

to

``````\includegraphics[*]{**.eps}
``````

The use of `letltxmacro` is required in order to cope with the optional argument of `\includegraphics`. See When to use `\LetLtxMacro`?

Alternatively, and perhaps much easier, you can use

``````\DeclareGraphicsExtensions{.eps}
``````
-