![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) |
| Guest | Re: Group extensions by size "Ant" <antgoodlife@gmail.com> wrote in message news:1176136308.451747.197050@y80g2000hsf.googlegroups.com... >I have a sample that does extensions by count for my F: drive, but how > do I do this by length instead of count? > > get-childitem -r c:\ | group extension | sort-object count -descending > | select -first 10 Probably not optimised for a complete drive scan, but basically equivalent to your sample: dir -r c:\ | group extension | select @{n="Size";e={($_.group | measure length -sum).sum}},name | sort size -desc | select -first 10 Jacques |
| | #3 (permalink) |
| Guest | Re: Group extensions by size Thank you, while I am sure this is close, it's throwing this error : PS F:\> dir -r F:\ | group extension | select @{n="Size";e={($_.group | measure length -sum).sum}},name | sort size -desc | select -first 10 Select-Object : The term 'measure' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:38 + dir -r F:\ | group extension | select <<<< @{n="Size";e={($_.group | measure length -sum).sum}},name | sort size -desc | select -first 10 Select-Object : The term 'measure' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and try again. At line:1 char:38 over and over.... Also, could you please explain this section so I learn a little without just getting the fish? select @{n="Size";e={($_.group | measure length -sum).sum}},name Thank you again... Thanks again... On Apr 9, 1:11 pm, "Jacques Barathon [MS]" <jbara...@online.microsoft.com> wrote: > "Ant" <antgoodl...@gmail.com> wrote in message > > news:1176136308.451747.197050@y80g2000hsf.googlegroups.com... > > >I have a sample that does extensions by count for my F: drive, but how > > do I do this by length instead of count? > > > get-childitem -r c:\ | group extension | sort-object count -descending > > | select -first 10 > > Probably not optimised for a complete drive scan, but basically equivalent > to your sample: > > dir -r c:\ | group extension | select @{n="Size";e={($_.group | measure length -sum).sum}},name | sort size -desc | select -rst 10 > > Jacques |
| | #4 (permalink) |
| Guest | Re: Group extensions by size > Thank you, while I am sure this is close, it's throwing this error : > PS F:\> dir -r F:\ | group extension | select @{n="Size";e={($_.group > | measure length -sum).sum}},name | sort size -desc | select -first 10 > Select-Object : The term 'measure' is not recognized as a cmdlet, > function, operable program, or script file. Verify the term and try > again. > At line:1 char:38 That's odd, it works here okay on Powershell V1.0. Try expanding 'measure' to 'measure-object' > Also, could you please explain this section so I learn a little > without just getting the fish? > select @{n="Size";e={($_.group | measure length -sum).sum}},name > > Thank you again... > I can't quite understand the hash-literal in the mid-section either. I see that n= can be expanded to name=, but any other token generates an invalid key error, same goes for e=, that must be a short-cut for something too, enum maybe? Looks like it's a way of populating the hashtable in-line, but can't find the relevant documentation. Thanks, Duncan. |
| | #5 (permalink) |
| Guest | Re: Group extensions by size Yes, measure-object was the trick.. (And I am using powershell version 1.0 too...) perhaps you have an alias... regardless I'm all set. Thanks again for your help, now onto deleting linux gzips from my home drive :-) PS F:\> dir -r F:\ | group extension | select @{n="Size";e={($_.group | measure-object length -sum).sum}},name | sort size -desc | select - first 10 Size Name ---- ---- 348529270 .gz 98309149 .exe 47478784 .nsf 47379546 .pdf 36364346 .jar 30728192 .ntf 29310093 .doc 16187033 .dll 10936641 .rtf 10219727 .txt On Apr 9, 3:12 pm, "Duncan Smith" <DSmith1...@googlemail.com> wrote: > > Thank you, while I am sure this is close, it's throwing this error : > > PS F:\> dir -r F:\ | group extension | select @{n="Size";e={($_.group > > | measure length -sum).sum}},name | sort size -desc | select -first 10 > > Select-Object : The term 'measure' is not recognized as a cmdlet, > > function, operable program, or script file. Verify the term and try > > again. > > At line:1 char:38 > > That's odd, it works here okay on Powershell V1.0. Try expanding > 'measure' to 'measure-object' > > > Also, could you please explain this section so I learn a little > > without just getting the fish? > > select @{n="Size";e={($_.group | measure length -sum).sum}},name > > > Thank you again... > > I can't quite understand the hash-literal in the mid-section either. > I see that n= can be expanded to name=, but any other token generates > an invalid key error, same goes for e=, that must be a short-cut for > something too, enum maybe? > > Looks like it's a way of populating the hashtable in-line, but can't > find the relevant documentation. > > Thanks, > > Duncan. |
| | #6 (permalink) |
| Guest | Re: Group extensions by size "Ant" <antgoodlife@gmail.com> wrote in message news:1176146219.534107.182510@p77g2000hsh.googlegroups.com... > Yes, measure-object was the trick.. (And I am using powershell version > 1.0 too...) perhaps you have an alias... regardless I'm all set. > Thanks again for your help, now onto deleting linux gzips from my home > drive :-) Yes, sorry about that. I have a script block in my profile which aliases all cmdlets having object as their name to their verb only (new-object -> new, measure-object -> measure, compare-object -> compare, etc). Re: the in-line hash, I can't tell you where it is documented but I am quite sure it is somewhere. Others in the PowerShell team may be able to guide you here. I am aware of those tokens: * Expression - abbreviated to e. Contains the code you want to execute, $_ being the current object. This token is common to all cmdlets that can use such hash. You can only the expression and nothing else, and then skip the "e=" part of the hash (eg. select {($_.group | measure-object length -sum).sum}). An example with another cmdlet than select: dir | group {"{0}{1}" -f $_.name[0],$_.extension[1]} * Name - abbreviated to n. Gives a name to the property you are returning from your expression. I have used it with select, not sure if it can apply to any other cmdlet. * Label - abbreviated to l. Replaces Name in formatting cmdlets. * Align - abbreviated to a. Decides of the alignment of text in formatting cmdlets. Can be "left", "right" or "center". Another example (completely useless, as all great examples are): dir | ft @{l="Initials";a="right";e={"{0}{1}" -f $_.name[0],$_.extension[1]}} -a There might be other formatting tokens, but I very rarely need them. Hope that helps, Jacques |
| |
| |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Contacts moving from group to group randomly. why? | Leon McCalla | Live Messenger | 0 | 3 Weeks Ago 11:55 AM |
| Messenger Group – Enjoy the group chat on your Windows Live Messen | Ethan Jone | Live Messenger | 0 | 04-27-2008 10:44 PM |
| Group-Object and getting the full GroupInfo (Group) output. | Tolli | PowerShell | 2 | 04-08-2008 11:15 AM |
| Maximum Contact Group Size | pennytaffy | Live Mail | 1 | 02-02-2008 01:17 AM |
| Windows Mail Contact Group option GROUP ONLY | PECHE RICE | Vista mail | 0 | 03-14-2007 01:11 PM |