<?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>n8blog &#187; Utilities</title>
	<atom:link href="http://www.n8gray.org/blog/category/projects/utilities/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.n8gray.org</link>
	<description>distraction in action</description>
	<lastBuildDate>Thu, 01 Jul 2010 18:21:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>New: relpath</title>
		<link>http://www.n8gray.org/blog/2004/11/17/new-relpath/</link>
		<comments>http://www.n8gray.org/blog/2004/11/17/new-relpath/#comments</comments>
		<pubDate>Wed, 17 Nov 2004 07:11:00 +0000</pubDate>
		<dc:creator>n8</dc:creator>
				<category><![CDATA[Utilities]]></category>

		<guid isPermaLink="false">http://www.n8gray.org/sandbox/wordpress/?p=70</guid>
		<description><![CDATA[This is a little script that calculates the shortest relative path from a directory to one or more arbitrary paths.  For example:



[n8gray@golux photos]$ pwd
/Users/n8gray/web/Sites/photos
[n8gray@golux photos]$ relpath . ~/Pictures/
../../Pictures
[n8gray@golux photos]$ relpath /usr/local /usr/local/bin/nedit
./bin/nedit
[n8gray@golux photos]$ relpath / /
./
[n8gray@golux photos]$ relpath . ..
../
[n8gray@golux photos]$ relpath . /usr/local ~/bin ../photos/Cats/index.html
../../../../usr/local
../../bin
./Cats/index.html




Caveat Emptor: Symbolic links are resolved when you give [...]]]></description>
			<content:encoded><![CDATA[<p>This is a little script that calculates the shortest relative path from a directory to one or more arbitrary paths.  For example:



<pre>[n8gray@golux photos]$ pwd
/Users/n8gray/web/Sites/photos
[n8gray@golux photos]$ relpath . ~/Pictures/
../../Pictures
[n8gray@golux photos]$ relpath /usr/local /usr/local/bin/nedit
./bin/nedit
[n8gray@golux photos]$ relpath / /
./
[n8gray@golux photos]$ relpath . ..
../
[n8gray@golux photos]$ relpath . /usr/local ~/bin ../photos/Cats/index.html
../../../../usr/local
../../bin
./Cats/index.html
</pre>



<p>Caveat Emptor: Symbolic links are resolved when you give a relative path but not when you give an absolute path.  I intend to make this more deterministic and controllable in the future.

<p>Get it <a href="/code/files/relpath">here</a>.  Python 2.3 required.<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.n8gray.org%2Fblog%2F2004%2F11%2F17%2Fnew-relpath%2F&amp;linkname=New%3A%20relpath"><img src="http://www.n8gray.org/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.n8gray.org/blog/2004/11/17/new-relpath/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
