<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>James Gregory &#187; NAnt</title>
	<atom:link href="http://jagregory.com/writings/category/nant/feed/" rel="self" type="application/rss+xml" />
	<link>http://jagregory.com</link>
	<description>Monkeying with the code</description>
	<lastBuildDate>Tue, 22 Jun 2010 11:07:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>getfilename NAnt task</title>
		<link>http://jagregory.com/writings/getfilename-nant-task/</link>
		<comments>http://jagregory.com/writings/getfilename-nant-task/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 23:38:03 +0000</pubDate>
		<dc:creator>James Gregory</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[NAnt]]></category>

		<guid isPermaLink="false">http://blog.jagregory.com/2008/03/12/getfilename-nant-task/</guid>
		<description><![CDATA[As part of my current quest to fully automate our build, I found my self needing the ability to copy a database backup from our remote server. The backup is in a folder along with several other backups, with a filename based on the date. I didn&#8217;t fancy trying to programmatically guess the filename, so [...]]]></description>
			<content:encoded><![CDATA[<p>As part of my current quest to fully automate our build, I found my self needing the ability to copy a database backup from our remote server. The backup is in a folder along with several other backups, with a filename based on the date. I didn&#8217;t fancy trying to programmatically guess the filename, so I wrote an NAnt task to grab the newest file in a directory. Thanks to <a href="http://blogs.geekdojo.net/rcase">Richard Case</a> for his overview of how to <a href="http://blogs.geekdojo.net/rcase/archive/2005/01/06/5971.aspx">create a custom NAnt task</a>.</p>
<p>The getfilename task simply gets the filename of a file in a directory, then pushes the name into the specified property. The filename to find can be based on the creation date, last modified date etc&#8230;</p>
<p>The attributes are as follows:</p>
<table class="format-table">
<thead>
<tr>
<th>Attribute</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody>
<tr>
<td>in</td>
<td>The directory to search</td>
<td>Yes</td>
</tr>
<tr class="alt">
<td>property</td>
<td>The property to push the filename into.</td>
<td>Yes</td>
</tr>
<tr>
<td>searchPattern</td>
<td>Wildcard search pattern for finding the file.</td>
<td>No</td>
</tr>
<tr class="alt">
<td>of</td>
<td>
				The file to get the filename of.</p>
<p>				<strong>NewestFile</strong> &#8211; The most recently created file<br />
				<strong>OldestFile</strong> &#8211; The oldest file in the directory<br />
				<strong>FirstModifiedFile</strong> &#8211; The file with the oldest last modified date<br />
				<strong>LastModifiedFile</strong> &#8211; The most recently modified file<br />
				<strong>FirstFile</strong> &#8211; The first file in the directory, using default sorting<br />
				<strong>LastFile</strong> &#8211; The last file in the directory, using default sorting
			</td>
<td>No &#8211; Defaults to NewestFile</td>
</tr>
</tbody>
</table>
<p>An example usage is:</p>
<pre name="code" class="xml">
&lt;?xml version=&quot;1.0&quot;?&gt;
&lt;project name=&quot;Example&quot; default=&quot;run&quot;&gt;
    &lt;target name=&quot;run&quot;&gt;
      &lt;getfilename of=&quot;NewestFile&quot; in=&quot;C:\path\to\backups&quot; searchPattern=&quot;*.bak&quot; property=&quot;filename&quot; /&gt;
      &lt;echo message=&quot;Filename: ${filename}&quot; /&gt;
    &lt;/target&gt;
&lt;/project&gt;
</pre>
<p>Foreseeable usage situations revolve around anything where you&#8217;d need to get the last modified, or newest file in a directory; backups, database scripts etc&#8230;</p>
<h4>Downloads</h4>
<p>The DeleGrid is open-source under the <a href="http://en.wikipedia.org/wiki/BSD_license">new BSD License</a>; read the license for what you’re allowed to do.</p>
<p>You can download the source here: <a href="http://jagregory.googlecode.com/files/JAGregory.NAntTasks-1.0-source.zip">Download Source</a>.<br />
You can download the latest binary here: <a href="http://jagregory.googlecode.com/files/JAGregory.NAntTasks-1.0.zip">Download Binary</a>.</p>
<p>The source is also accessible from Subversion at: <a href="http://jagregory.googlecode.com/svn/trunk/JAGregory.NAntTasks/">http://jagregory.googlecode.com/svn/trunk/JAGregory.NAntTasks/</a> (using user jagregory-read-only)</p>
<p><a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fblog.jagregory.com%2f2008%2f03%2f12%2fgetfilename-nant-task%2f"><img src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fblog.jagregory.com%2f2008%2f03%2f12%2fgetfilename-nant-task%2f" border="0" alt="kick it on DotNetKicks.com" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jagregory.com/writings/getfilename-nant-task/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
