Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Search filenames only

Reply
 
Old 07-04-2009   #1 (permalink)


Vista Home Premium 32bit
 
 

Search filenames only

Hello,

I'm a beginner in powershell.

I'm wondering how I could search a directory of files for a match that occurs not in the contents of the files, but only in the names of the files?

In Linux (bash), I could do:

Code:
ls | grep -i "match me"
Which would search for "match me" within the filenames of all the files in the current directory.

What about powershell?

My System SpecsSystem Spec
Old 07-04-2009   #2 (permalink)
Flowering Weeds


 
 

Re: Search filenames only

Quote:

>
> In Linux (bash), I could do:
>
>
> Code:
> --------------------
> ls | grep -i "match me"
> --------------------
>
Mmm since this is the year of data parsing
and charting (and yes Regex is also included)
then perhaps for a large numbers of files - FYI

Remember, Windows PowerShell
is not a data parser, but is a
Windows-based automation tool,
meant to pass "data"
from tool to tool, to tool,
until output (or whatever)!

Mmm automate tools and there really are
lots of Windows-based tools available,
for Windows PowerShell to automateI

So for here perhaps (like so many IT Pros)
automate a data parser tool within powershell.exe!

Perhaps Microsoft's IIS's (local or remote)
data parser, Log Parser!

PS > LogParser.exe -h -i:fs

Input format: FS (FileSystem properties)
Returns properties of files and folders

"Log Parser" - Bing
http://www.bing.com/search?q=%22Log+Parser%22

And surely after all these years,
any PowerShell user can help
one automate Log Parser too!

As always enjoy the automation
of tools within the Windows-based,
..NET aware, WPF accessible,
admin's automation tool,
powershell.exe!


My System SpecsSystem Spec
Old 08-11-2009   #3 (permalink)


Vista Home Premium 32bit
 
 

Re: Search filenames only

It's been a little while, but I accidentally bumped into the solution the other day.

In short form:

Code:
ls |? {$_.Name -match "match me"}
Long form:

Code:
Get-ChildItem | Where-Object {$_.Name -match "match me"}
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
More missing filenames! Vista General
Missing Filenames General Discussion
Filenames Do Not Match Vista file management
Green Filenames - Why? Vista General
filenames with [ characters PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46