ant contrib - ant - Need to get only file name without extension and entire path -


i have couple of .xml files in folder.i want loop on each .xml file.it getting fine. want take .xml file name without entire path. how can achieve that.?

i using below piece of code file name.

<target name="createapplicationdaa">   <for param="program">     <path>       <fileset dir="${soaprojectname}/composites" includes="**/*.xml"/>     </path>     <sequential>     <propertyregex override="yes" property="file"  input="@{program}" regexp=".*/([^\.]*)\.xml" replace="\1"/>         <echo>@{program}</echo>     </sequential>   </for> </target> 

the folder name c:/abc/bcd/cde first.xml,second.xml,third.xml,fourth.xml .xml files in cde folder. when execute above code getting entire path c:/abc/bcd/cde/first.xml ..etc want first first.xml , second second.xml. please me out achieve file name.

edit after further investigation (see comments)

no need regex when using basename task. properties once set immutable in vanilla ant, when using basename task within loop, property filename holds value of first file.
therefore antcontrib var task unset="true" has used :

 <for param="program">   <path>    <fileset dir="c:\whatever" includes="**/*.xml"/>   </path>   <sequential>    <var name="filename" unset="true"/>    <basename property="filename" file="@{program}" suffix=".xml"/>    <echo>${filename}</echo>   </sequential>  </for> 
  1. the regex doesn't work me on windowsbox
  2. you're echoing original filename when using <echo>@{program}</echo>
    use <echo>${file}</echo> instead

means :

<for param="program">  <path>   <fileset dir="c:\whatever" includes="**/*.xml"/>  </path>  <sequential>  <propertyregex override="yes" property="file" input="@{program}" regexp=".:\\.+\\(\w+).+" replace="\1"/>  <echo>${file}</echo>  </sequential> </for> 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -