MSH: Counting and Deleting Files

In my MKS Toolkit past I would have executed the following to delete a certain type of file:
 
find .  -name "~*.*" -exec rm -f {} ;
 
Actually before executing this I might have done a paranoid count of all files and ~*.* files like so:
 
find . -type f | wc -l
find . -name "~*.*" | wc -l
 
In moving to MSH, I now count the files like this:
 
gci . -rec | where {!$_.MshIsContainer} | measure-object
gci . -rec ~*.* | measure-object
 
then I delete those files like this:
 
gci . -rec ~*.* | remove-item -force
 
BTW, gci is just an alias for get-childitem. 
Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

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