Ant - Change extension on file

I have an exec in Ant that looks like this:

<exec taskname = "convert"
executable = "convert"
failonerror = "true">
<arg line="in=@{file} out=???" />
</exec>

I want to use a command that converts a file. The in infile name has one extension and the out file another, but the rest of the file name should be the same. How do I get it this way?

The arg line is messed up since I don't know what to write.
mdolandAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
You could use a property for the name up to the extension
CEHJCommented:
<arg line="in=@${file.without.extension}.in" out="${file.without.extension}.out" />
CEHJCommented:
Actually that should maybe be more like:

<arg line="in=${file.without.extension}.in" />
<arg line="out=${file.without.extension}.out" />

but i think you probably get the general principle
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Mick BarryJava DeveloperCommented:
try:

<arg line="in=${file}.in out=${file}.out" />
CEHJCommented:
Each argument should be tagged separately (that's what they're for)
mdolandAuthor Commented:
It sounds straight, but this is the way it looks outside:

<for param="file">
                              <!-- Perform encoding for all files included in the fileset specified by the macro attributes -->
                              <path>
                                    <fileset dir="@{dir}">
                                          <include name="@{includes}" />
                                          <exclude name="@{excludes}" />
                                    </fileset>
                              </path>
                              <sequential>
                                    <exec      taskname      = "convert"
                                                executable      = "convert"
                                                failonerror      = "true">
                                          <arg line="in=@{file} out=???" />

                                    </exec>
                                    <!-- Remove files if keeporiginals attribute is not set to true -->
                                    <if>
                                          <equals arg1="@{keeporiginals}" arg2="false" casesensitive="false" />
                                          <then>
                                                <delete quiet="true" file="@{file}" />
                                          </then>
                                    </if>
                              </sequential>
</for>



I get it in as a filesset from an include statement, but I don't get it how I should do to get the extension off there.
CEHJCommented:
If you know the extension, you can use

http://ant.apache.org/manual/CoreTasks/basename.html

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mick BarryJava DeveloperCommented:
if you know the output extension the using basename mentioned by cehj would allow you to do:


<basename property="filebase" file="${file}"/>
<arg line="in=@{file} out=${filebase}.out" />
CEHJCommented:
:-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.