I'm trying to grab a set of files from a directory, move it to another, and prefix all the names with a variable as I move them.
My theory is to loop through each file with a fornext and use a fileset to select my files. However, I can not seem to get the fileset and fornext to be happy. The documentation for the 'in' parameter for fornext is completely confusing. Here is basically what I'm trying to start off <foreach item="File" property="filename"> <in> <fileset basedir="./"> <include name="*.data" /> </fileset> </in> <echo>${filename}</echo> </foreach> This does not work because it says <in> does not support the nested <fileset>. The help page says ----------- Nested Elements: <in> Stuff to operate in. Just like the in attribute, but supports more complicated things like a <fileset> and such. ------------ If I leave off in, it complains as well. Basically I'm trying to take all files in the current directory named *.data and rename them p_*.data I've found one blog post that lead me to this solution <foreach item="File" in="./" property="fileName"> <!-- If the file has the .data extension --> <if test="${string::to-lower(path::get-extension(fileName)) == '.data'}"> <!-- Rename the file with prefix --> <move file="${fileName}" tofile="${path::combine(path::get-directory-name(fileName), 'p_' + path::get-file-name(fileName))}" /> </if> </foreach> Which works except, the if condition seems like it should be solved when the set is created.. and while the scenario works with the constant 'p_' in there, if I want to make p a property, it fails saying unexpected token. Why can't a property work there? And why is 'filename' in the path statements above listed without the $ ? TIA! -Steve ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ NAnt-users mailing list NAnt-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nant-users