Sonntag, 15. März 2009

Some thoughts about find and search on Windows (part I).

In unix world there are the commands find and grep which help to locate files in the file system. Not trivial, but they do an honest job.

In Windows world search capabilities changed from version to version. In my opinion to the worse.

I still have a running Windows 2000 Box at hand and searching for files is one of rare tasks I still use it.

In Windows XP I first have to kick away some insulting dog.

And Vista is spending a lot of its time indexing the filesystem and nearly never gives the answers I want.

Windows 7 wastes less time indexing, but doesn't answer my questions either.


Perhaps to express my wishes to todays software designers, I have to describe a clear set of working cases. Though that they have to solve my problem or have to admit that they can't handle it.


Work case 1:
I know that I worked on a PowerShell Script some days ago,
it must be located in some dedicated directory or in one of my working directories.
I'm not sure whether it was on a local drive or on a network share.


Using Windows 2000 or Windows XP the OS search function helps.


Using Vista or Windows 7 windows search never found the files I was looking for.




Note 1: PowerShell uses other extension but the simple .ps1 to e.g. .psm1 and .ps1xml


Note 2: Selecting a single root to start the search is not sufficient


Note 3: Not all pathes may be accessiable all the time


Let me show you my PowerShell solution.

Note that I don't like having my files neither on a system partition nor within my profile but on different local drive or net-share.


# list of directories, which contain the places where I use to store my PowerShell scripts
# some are local and some are not wllways connected
$ps_roots = (
'I:\bin\Scripts',
'I:\codeplex\ise-cream',
'I:\PoshCode',
'U:\scripts',
'U:\scripts'
)

# show the pathes that are currently accessible
$ps_roots |? { (Test-path $_) }

# usual PowerShell File Extensions
$ps_extensions = '*.ps1', '*.psm1', '*.ps1xml'

# now show files with any of these extensions in my pathes
$ps_roots |? { (Test-path $_) } | gci -rec -include $ps_extensions


# now show files with any of these extensions in my pathes changed within the last 10 days
$ps_roots |? { (Test-path $_) } | gci -rec -include $ps_extensions| Where-object {((Get-date) - $_.LastWriteTime).days -lt 10 }



Next time I'm going to to show some refinements based on file contents.

Keine Kommentare:

Kommentar veröffentlichen