<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Translating from cmd.exe to PowerShell: dir</title>
	<atom:link href="http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/feed/" rel="self" type="application/rss+xml" />
	<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/</link>
	<description>Discovering and learning</description>
	<pubDate>Wed, 03 Dec 2008 21:38:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Joaquin Menchaca</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-14821</link>
		<dc:creator>Joaquin Menchaca</dc:creator>
		<pubDate>Wed, 25 Jul 2007 03:55:40 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-14821</guid>
		<description>I just have to say thank you for this information.  Most books and material just focus on object access and stuff, but not much in the way of practical material do do real world shell stuff. 

This material helps.</description>
		<content:encoded><![CDATA[<p>I just have to say thank you for this information.  Most books and material just focus on object access and stuff, but not much in the way of practical material do do real world shell stuff. </p>
<p>This material helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: trix</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-2860</link>
		<dc:creator>trix</dc:creator>
		<pubDate>Wed, 18 Oct 2006 14:15:49 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-2860</guid>
		<description>Im a powershell newbie and this took me ages so i would be greatfull if anyone knows of a better way.  I essentailly wanted the powershell dir to behave like the cmd.exe dir and put directories at the top.  this is what i ended up with:

$results = Get-ChildItem &#124; where-Object { $_.PSIsContainer -eq 1 }
$results2 = Get-ChildItem &#124; Where-Object { $_.PSIsContainer -eq 0 }
$results+$results2

with
remove-item alias:\dir
set-alias dir C:\\Cmd-Dir.ps1
in my profile

is there a simpler way!? 

thanks</description>
		<content:encoded><![CDATA[<p>Im a powershell newbie and this took me ages so i would be greatfull if anyone knows of a better way.  I essentailly wanted the powershell dir to behave like the cmd.exe dir and put directories at the top.  this is what i ended up with:</p>
<p>$results = Get-ChildItem | where-Object { $_.PSIsContainer -eq 1 }<br />
$results2 = Get-ChildItem | Where-Object { $_.PSIsContainer -eq 0 }<br />
$results+$results2</p>
<p>with<br />
remove-item alias:\dir<br />
set-alias dir C:\\Cmd-Dir.ps1<br />
in my profile</p>
<p>is there a simpler way!? </p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harri</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1993</link>
		<dc:creator>Harri</dc:creator>
		<pubDate>Thu, 10 Aug 2006 06:11:34 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1993</guid>
		<description>Also dot (.) seems to work in function name - so you can define: function cd..{set-location ..} in profile.</description>
		<content:encoded><![CDATA[<p>Also dot (.) seems to work in function name - so you can define: function cd..{set-location ..} in profile.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBMwS</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1829</link>
		<dc:creator>DBMwS</dc:creator>
		<pubDate>Tue, 01 Aug 2006 01:52:48 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1829</guid>
		<description>NP, there Tommy,  I just wanted to point out that there are many ways(too many possibly ? ;)) to do the same thing.

It's just amazing how much you can do with just one line with PowerShell... ;)</description>
		<content:encoded><![CDATA[<p>NP, there Tommy,  I just wanted to point out that there are many ways(too many possibly ? ;)) to do the same thing.</p>
<p>It&#8217;s just amazing how much you can do with just one line with PowerShell&#8230; ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tommy Williams</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1815</link>
		<dc:creator>Tommy Williams</dc:creator>
		<pubDate>Sun, 30 Jul 2006 21:21:14 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1815</guid>
		<description>Thanks for the pointer to using IO.FileAttributes and, in particular, the use of the binary-and comparison operator. I'm going to spend some time reading through your blog, too -- looks like you have some good info there.</description>
		<content:encoded><![CDATA[<p>Thanks for the pointer to using IO.FileAttributes and, in particular, the use of the binary-and comparison operator. I&#8217;m going to spend some time reading through your blog, too &#8212; looks like you have some good info there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBMwS</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1814</link>
		<dc:creator>DBMwS</dc:creator>
		<pubDate>Sun, 30 Jul 2006 21:06:15 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1814</guid>
		<description>Woops.
Sorry about reposting. I have forgotten to include filter for directory.  So would you moderate my previous post to include "-and $_.PsIsContainer"?
Here is the revised version
ls -fo &#124; ? { ($_.attributes -band 2) -and $_.PsIsContainer}</description>
		<content:encoded><![CDATA[<p>Woops.<br />
Sorry about reposting. I have forgotten to include filter for directory.  So would you moderate my previous post to include &#8220;-and $_.PsIsContainer&#8221;?<br />
Here is the revised version<br />
ls -fo | ? { ($_.attributes -band 2) -and $_.PsIsContainer}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DBMwS</title>
		<link>http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1813</link>
		<dc:creator>DBMwS</dc:creator>
		<pubDate>Sun, 30 Jul 2006 21:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://twwilliams.com/blog/2006/07/30/translating-from-cmdexe-to-powershell-dir/#comment-1813</guid>
		<description>For dir /a:hd, although I liked your approach on displaying hidden files, there is another solution that i have come up with(well it's been around to be honest) and it's a bit longer

My solution would basically check the "flag" of attribute instead of comparing the string.

&lt;b&gt;Longest version:&lt;/b&gt;
ls -Force &#124; ? { ($_.attributes -band [System.IO.FileAttributes]"Hidden") -eq [System.IO.FileAttributes]"Hidden" }

You can leave out "System" and it becomes
&lt;b&gt;Shorter version:&lt;/b&gt;
ls -Force &#124; ? { ($_.attributes -band [IO.FileAttributes]"Hidden") -eq [IO.FileAttributes]"Hidden" }

Now, there is no need to check if value of "($_.attributes -band [IO.FileAttributes]"Hidden")" is equal to the value of '[IO.FileAttributes]"Hidden"' at all, so
&lt;b&gt;Even Shorter version:&lt;/b&gt;
ls -Force &#124; ? { ($_.attributes -band [IO.FileAttributes]"Hidden") }

Well, you can't leave out "[IO.FileAttributes]" type there because without casting "HIdden", to FileAttributes, PowerShell would consider "Hidden" as string

Btw, you can actually substitute '-band [IO.FileAttributes]"Hidden"' with "-band 2" since the enum value of Hidden is 2.

&lt;b&gt;The SHORTEST version:&lt;/b&gt;
# but not recommended for readability issue IMHO
ls -fo &#124; ? { ($_.attributes -band 2) }</description>
		<content:encoded><![CDATA[<p>For dir /a:hd, although I liked your approach on displaying hidden files, there is another solution that i have come up with(well it&#8217;s been around to be honest) and it&#8217;s a bit longer</p>
<p>My solution would basically check the &#8220;flag&#8221; of attribute instead of comparing the string.</p>
<p><b>Longest version:</b><br />
ls -Force | ? { ($_.attributes -band [System.IO.FileAttributes]&#8220;Hidden&#8221;) -eq [System.IO.FileAttributes]&#8220;Hidden&#8221; }</p>
<p>You can leave out &#8220;System&#8221; and it becomes<br />
<b>Shorter version:</b><br />
ls -Force | ? { ($_.attributes -band [IO.FileAttributes]&#8220;Hidden&#8221;) -eq [IO.FileAttributes]&#8220;Hidden&#8221; }</p>
<p>Now, there is no need to check if value of &#8220;($_.attributes -band [IO.FileAttributes]&#8220;Hidden&#8221;)&#8221; is equal to the value of &#8216;[IO.FileAttributes]&#8220;Hidden&#8221;&#8216; at all, so<br />
<b>Even Shorter version:</b><br />
ls -Force | ? { ($_.attributes -band [IO.FileAttributes]&#8220;Hidden&#8221;) }</p>
<p>Well, you can&#8217;t leave out &#8220;[IO.FileAttributes]&#8221; type there because without casting &#8220;HIdden&#8221;, to FileAttributes, PowerShell would consider &#8220;Hidden&#8221; as string</p>
<p>Btw, you can actually substitute &#8216;-band [IO.FileAttributes]&#8220;Hidden&#8221;&#8216; with &#8220;-band 2&#8243; since the enum value of Hidden is 2.</p>
<p><b>The SHORTEST version:</b><br />
# but not recommended for readability issue IMHO<br />
ls -fo | ? { ($_.attributes -band 2) }</p>
]]></content:encoded>
	</item>
</channel>
</rss>
