<?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>Bahramov's Personal Blog &#187; PowerShell</title>
	<atom:link href="http://www.bahramov.com/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bahramov.com</link>
	<description>Computers, databases, networks and virtualization</description>
	<lastBuildDate>Fri, 24 Jun 2011 12:05:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PowerShell script to list any desired file type(s)</title>
		<link>http://www.bahramov.com/2009/09/01/powershell-script-to-list-any-desired-file-types/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://www.bahramov.com/2009/09/01/powershell-script-to-list-any-desired-file-types/#comments</comments>
		<pubDate>Tue, 01 Sep 2009 09:01:56 +0000</pubDate>
		<dc:creator>Zaur Bahramov</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Windows Scripting]]></category>

		<guid isPermaLink="false">http://www.bahramov.com/2009/09/01/powershell-script-to-list-any-desired-file-types/</guid>
		<description><![CDATA[Hereâ€™s a PowerShell script that produces the list of desired file types (jpg, bmp, exe, dll, etc.)
Change $path=â€C:\â€ to desired directory.
Change â€˜.bmpâ€™ to desired file extension.
If you need to find more that one file type, then add â€œ-or ($file.Extension -eq &#8216;.some_extension&#8217;)â€ in the if statement, e.g.:
if (($file.Extension -eq &#8216;.bmp&#8217;) -or ($file.Extension -eq &#8216;.jpg&#8217;))
if (($file.Extension -eq [...]]]></description>
			<content:encoded><![CDATA[<p>Hereâ€™s a PowerShell script that produces the list of desired file types (jpg, bmp, exe, dll, etc.)</p>
<p>Change $path=â€C:\â€ to desired directory.</p>
<p>Change â€˜.bmpâ€™ to desired file extension.</p>
<p>If you need to find more that one file type, then add â€œ-or ($file.Extension -eq <span class="rem">&#8216;.some_extension&#8217;)</span>â€ in the if statement, e.g.:</p>
<p><strong><span class="kwrd">if</span> (($file.Extension -eq <span class="rem">&#8216;.bmp&#8217;) -or ($file.Extension -eq <span class="rem">&#8216;.jpg&#8217;)</span>)</span></strong></p>
<p><strong>if (($file.Extension -eq &#8216;.bmp&#8217;)-or ($file.Extension -eq &#8216;.jpg&#8217;) -or ($file.Extension -eq &#8216;.gif&#8217;))</strong></p>
<pre class="csharpcode">$path=<span class="str">&quot;c:\&quot;</span>
<span class="kwrd">function</span> showdir {
param (
$path
)
$files=<span class="kwrd">Get</span>-ChildItem $path
foreach ($file <span class="kwrd">in</span> $files) {
<span class="kwrd">if</span> ($file.PSIsContainer) {
showdir -path $file.FullName
}
<span class="kwrd">else</span> {
<span class="kwrd">if</span> (($file.Extension -eq <span class="rem">'.bmp')) {</span>
$f=gwmi -<span class="kwrd">Class</span> CIM_DataFile -Filter <span class="str">&quot;Name='$(add_slhs($file.FullName))'&quot;</span>
Write-Host $file.FullName,$f.Version
}
}
}
}
<span class="kwrd">function</span> add_slhs($src) {
$dst=<span class="str">&quot;&quot;</span>
<span class="kwrd">for</span> ($i=0;$i -lt $src.length;$i++) {
<span class="kwrd">if</span> ($src[$i] -ne <span class="str">&quot;\&quot;</span>) {
$dst=$dst+$src[$i]
}
<span class="kwrd">else</span> {
$dst=$dst+$src[$i]+<span class="str">&quot;\&quot;</span>
}
}
<span class="kwrd">return</span> $dst
} 

showdir -path $path</pre>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bahramov.com/2009/09/01/powershell-script-to-list-any-desired-file-types/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

