Home > Uncategorized > Powershell – feel the power

Powershell – feel the power

I find it amusing and inspiring to follow the codeplex daily summary. Today I stumbled upon a project called file endings. A C# application claiming the following features:

  • Searching for all file-endings in a folder with its subfolders
  • showing all files with a choosen file-ending
  • Options:
    • Search-Option: Casesensitive (On/Off). If casesensitive is on .MP3 is not the same as .mp3. If its off it’s the same.
    • Delete all files with the choosen file-ending.

To clarify, file endings in this context means file extensions. To me, the features provided are just simple one liners in powershell.

# Search for all extensions in a folder and its sub folders
dir -r | group extension

# Show all files with a choosen extension (in this example .cs)
1: dir –r –filter *.cs  
2: dir –r | ? { $_.Extension –eq “.cs” }

(pipe result to out-gridview for a fancy display)

# Case sensitive search
dir -r | ? { $_.Extension -cmatch "\.FIRST" }

# Delete matching files
dir –r –filter *.cs | del

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

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

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: