Created
June 4, 2015 21:37
-
-
Save refactorsaurusrex/6404d4975f1613989f76 to your computer and use it in GitHub Desktop.
How to edit the content of a subset of files from within a directory using NAnt. In this example, I iterate recursively through all paths contained within `C:\somePath\dbDirectory\` for all files with the extension of `.sql.template`, load the file, replace all instances of `@DBNAME@` with the value of `${database.name}`, and save the edited fil…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<foreach item="File" property="filename"> | |
<in> | |
<items> | |
<include name="C:\somePath\dbDirectory\**.sql.template"/> | |
</items> | |
</in> | |
<do> | |
<loadfile file="${filename}" property="fileContents"> | |
<filterchain> | |
<replacetokens> | |
<token key="DBNAME" value="${database.name}"/> | |
</replacetokens> | |
</filterchain> | |
</loadfile> | |
<echo file="${string::replace(filename, '.template', '')}" | |
message="${fileContents}" /> | |
</do> | |
</foreach> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment