Searching files in Windows with Powershell

06Aug09

The new (well, not that new now) Windows search is way annoying, so I thought may be I could use Powershell for searching. This is how to do it (best do it on one line):

 foreach ($file in get-Childitem . -include *svn* -force -recurse)
   { $file.fullname }

The -force is to make it include the hidden files in the results. A bit shorter, but arguably less readable if you don’t know Powershell:

 get-Childitem . -include *svn* -force -recurse
    | foreach ($_) { $_.fullname }

I bet you can go even shorter, I don’t really know Powershell, though it loos very, very powerful. Naturally.

Anyway, now I can do what I originally intended and blast all the svn info from my project, like so:

 get-Childitem . -include *svn* -force -recurse
   | foreach ($_) { remove-item $_ -recurse -force }
Advertisement


No Responses Yet to “Searching files in Windows with Powershell”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.