<?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>Mega-ZBlog &#187; batch scripts</title>
	<atom:link href="http://www.mzzt.net/tag/batch-scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mzzt.net</link>
	<description>You are here.</description>
	<lastBuildDate>Sat, 07 Jan 2012 23:53:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Display the Path in the Command Prompt Title Bar</title>
		<link>http://www.mzzt.net/2008/08/27/display-the-path-in-the-command-prompt-title-bar/</link>
		<comments>http://www.mzzt.net/2008/08/27/display-the-path-in-the-command-prompt-title-bar/#comments</comments>
		<pubDate>Thu, 28 Aug 2008 01:54:47 +0000</pubDate>
		<dc:creator>Dan Bugglin</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[batch scripts]]></category>
		<category><![CDATA[command prompt]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.mzzt.net/2008/08/27/display-the-path-in-the-command-prompt-title-bar/</guid>
		<description><![CDATA[Well I messed around a bit and came up with a rather nice solution. This emulates a feature of Linux&#8217;s gnome-terminal where you can set the titlebar to always reflect the terminal&#8217;s current directory.Scroll down for code and instructions, or read on for &#8220;the process&#8221;. I used this as a basis, but there are a [...]]]></description>
			<content:encoded><![CDATA[<p>Well I messed around a bit and came up with a rather nice solution.  This emulates a feature of Linux&#8217;s gnome-terminal where you can set the titlebar to always reflect the terminal&#8217;s current directory.<br /><span id="more-46"></span><br />Scroll down for code and instructions, or read on for &#8220;the process&#8221;.</p>
<p>I used <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;98578">this</a> as a basis, but there are a number of things wrong with that article.  First of all, the %=c:% variable returns the current directory on C:, not on the current drive.  Since everyone except maybe some ultralight laptop owners have more than just a C: drive (I spend most of my time on E:, F:, and G: myself) this is unacceptable to me.</p>
<p>I quick search turned up %cd% which returns the current directory.  Much nicer.</p>
<p>Now we have another little problem in the form of an extra prompt line that appears.  I discovered by inserting &#8220;echo off&#8221; (which suppresses the prompt) before the first command in the doskey macro, then &#8220;echo on&#8221; at the end, this problem goes away quite nicely.  I was almost done.</p>
<p>Then I just have to duplicate this doskey macro for other commands the article fails to consider, for example pushd and popd, plus all the drive letters.  A for loop takes care of the latter, although I still can&#8217;t avoid the tedious typing of every letter in the alphabet (I need to start using powershell or cygwin bash or something).</p>
<p>In the end, here is what I have.  Place both files in your system path somewhere (C:\WINDOWS\system32 meets this requirement).</p>
<p>titlepath.cmd<br />
<blockquote>@echo off<br />doskey cd=echo off$Tcd $*$Ttitlepathhelper$Techo on<br />doskey chdir=echo off$Tchdir $*$Ttitlepathhelper$Techo on<br />doskey pushd=echo off$Tpushd $*$Ttitlepathhelper$Techo on<br />doskey popd=echo off$Tpushd $*$Ttitlepathhelper$Techo on<br />for %%x in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do doskey %%x:=echo off$T%%x: $*$Ttitlepathhelper$Techo on<br />titlepathhelper</p></blockquote>
<p>titlepathhelper.cmd<br />
<blockquote>@title %cd%</p></blockquote>
<p>You&#8217;ll notice titlepath takes a little bit to churn away&#8230; if it bothers you, you can remove some of the drive letters from the for list or remove that line completely if you don&#8217;t mind the title not updating when you change drives.</p>
<p>One last thing is if you want this to happen every time you launch a command prompt without having to type titlepath in.</p>
<p>Open HKEY_CURRENT_USER\Software\Microsoft\Command Processor in Registry Editor and make an AutoRun string value and set it to titlepath.cmd.  Interestingly my batch file shouldn&#8217;t work at all according to <a href="http://blogs.msdn.com/oldnewthing/archive/2007/11/21/6447771.aspx">this caveat</a>, but I can&#8217;t get it to AutoRun when running through a for loop&#8230; odd.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mzzt.net/2008/08/27/display-the-path-in-the-command-prompt-title-bar/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

