How can I parse a file path and get its parent's parent's directory?
ant
Solution
You could use the Ant `dirname` task, and call it as many times as you need to get parents, parents of parents, etc.:
<dirname file="${jar}" property="jar.dir" />
<dirname file="${jar.dir}" property="jar.dir.parent" />
<dirname file="${jar.dir.parent}" property="jar.dir.grandparent" />
(Your example result looks like the parent of the directory holding the jar (i.e. `jar.dir.parent`, but you mention parent's parent.)
Problem
Using Ant - in a buildfile - how can I parse a file path and get its parent's parent's directory? ``` <target name="test"> <property name="jar" value="D:\F\D\r\org\springframework\spring-beans\3.0.7.R\spring-beans.jar" /> <echo>${jar}</echo> </target> ``` I want to get this result: ``` D:\F\D\r\org\springframework\spring-beans ```