简体   繁体   中英

ANT: Replace String in file with Filename itself

I have a situation where I need to scan through a large number of .xsd files, and replace an instance of a string with another string based on the file name of the current schema being examined.

For example: I wish to replace the string: 'DataSet' in file1.xsd with the string 'file1DataSet' I wish to replace the string: 'DataSet' in file2.xsd with the string 'file2DataSet' and so on until all schemas have been modified.

I would like to know if there is anyway to do this without using the ant-contrib for loops.

You could try the <replace> task if you have a generally good idea how many schemas you have. The <replaceRegex> might be able to do it without looping.

Ant isn't really a programming language where you can loop. If you can do everything in one pass, that's great, but once you start really manipulating files, Ant runs into limitations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM