![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | stoopid newb question ok so I have the following - all on one line. ls c:\ -rec | where {$_.mode -like "d*"} | foreach {$di.getfolder($_.fullname).size/1024/1024} $di = fso the above line returns the folder size correctly but I can't seem to find a way to output both the fullname and the size, any help would be appreciated! tr |
My System Specs![]() |
| | #2 (permalink) |
| | RE: stoopid newb question this would work PS> ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = $di.getfolder($_.fullname).size/1mb; Write-Host $_.fullname $size } -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "tonyr" wrote: > ok so I have the following - all on one line. > > ls c:\ -rec | where {$_.mode -like "d*"} | foreach > {$di.getfolder($_.fullname).size/1024/1024} > > $di = fso > the above line returns the folder size correctly but I can't seem to find a > way to output both the fullname and the size, any help would be appreciated! > tr > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: stoopid newb question On Aug 14, 10:48 am, tonyr <to...@discussions.microsoft.com> wrote: > ls c:\ -rec | where {$_.mode -like "d*"} | foreach > {$di.getfolder($_.fullname).size/1024/1024} > > $di = fso $objFSO = New-Object -com scripting.filesystemobject $dirs = ls c:\ -rec | where { $_.PSIsContainer } # Another way to get the directories $dirs | % { "$($_.fullname) $($objFSO.getfolder($_).size/1024/1024)" } I imagine there's prettier ways to do this. ![]() |
My System Specs![]() |
| | #4 (permalink) |
| | RE: stoopid newb question this gives a prettier output ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = $di.getfolder($_.fullname).size/1mb; "{0,9} {1,2} " -f $size, $_.fullname } -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "tonyr" wrote: > ok so I have the following - all on one line. > > ls c:\ -rec | where {$_.mode -like "d*"} | foreach > {$di.getfolder($_.fullname).size/1024/1024} > > $di = fso > the above line returns the folder size correctly but I can't seem to find a > way to output both the fullname and the size, any help would be appreciated! > tr > |
My System Specs![]() |
| | #5 (permalink) |
| | RE: stoopid newb question dangit I tried something very similar not sure why it did not work! thanks very much "RichS" wrote: > this would work > > PS> ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = > $di.getfolder($_.fullname).size/1mb; Write-Host $_.fullname $size } > -- > Richard Siddaway > Please note that all scripts are supplied "as is" and with no warranty > Blog: http://richardsiddaway.spaces.live.com/ > PowerShell User Group: http://www.get-psuguk.org.uk > > > "tonyr" wrote: > > > ok so I have the following - all on one line. > > > > ls c:\ -rec | where {$_.mode -like "d*"} | foreach > > {$di.getfolder($_.fullname).size/1024/1024} > > > > $di = fso > > the above line returns the folder size correctly but I can't seem to find a > > way to output both the fullname and the size, any help would be appreciated! > > tr > > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: stoopid newb question cool in just these two replys I've learned loads of info! thanks. tr "Hal Rottenberg" wrote: > On Aug 14, 10:48 am, tonyr <to...@discussions.microsoft.com> wrote: > > ls c:\ -rec | where {$_.mode -like "d*"} | foreach > > {$di.getfolder($_.fullname).size/1024/1024} > > > > $di = fso > > $objFSO = New-Object -com scripting.filesystemobject > $dirs = ls c:\ -rec | where { $_.PSIsContainer } # Another way to get > the directories > $dirs | % { "$($_.fullname) $($objFSO.getfolder($_).size/1024/1024)" } > > I imagine there's prettier ways to do this. ![]() > > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: stoopid newb question On Aug 14, 11:24 am, RichS <Ri...@discussions.microsoft.com> wrote: > this gives a prettier output > > ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = > $di.getfolder($_.fullname).size/1mb; "{0,9} {1,2} " -f $size, $_.fullname } And here's a link about the format operator "-f". http://www.computerperformance.co.uk..._-f_format.htm (I'm still trying to grok this one myself.) |
My System Specs![]() |
| | #8 (permalink) |
| | Re: stoopid newb question "tonyr" <tonyr@discussions.microsoft.com> wrote in message news:F9E889E6-E7D7-48F1-989D-7FD096B1CF5C@microsoft.com... > dangit I tried something very similar not sure why it did not work! thanks > very much > > "RichS" wrote: > >> this would work >> >> PS> ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = >> $di.getfolder($_.fullname).size/1mb; Write-Host $_.fullname $size } BTW I would recommend using the PSIsContainer property to filter out directories e.g.: gci c:\ -r | ?{$_.PSIsContainer} | %{"{0} {1} MB" -f $_.fullname, ($di.getFolder($_.fullname).size/1MB)} -- Keith |
My System Specs![]() |
| | #9 (permalink) |
| | Re: stoopid newb question There is an awful lot in the format operator. It is well worth getting to know. Also check out the articles on msdn about using it -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Hal Rottenberg" wrote: > On Aug 14, 11:24 am, RichS <Ri...@discussions.microsoft.com> wrote: > > this gives a prettier output > > > > ls c:\ -rec | where{$_.mode -like "d*"} | foreach{ $size = > > $di.getfolder($_.fullname).size/1mb; "{0,9} {1,2} " -f $size, $_.fullname } > > And here's a link about the format operator "-f". > > http://www.computerperformance.co.uk..._-f_format.htm > > (I'm still trying to grok this one myself.) > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Probably a complete newb question | Network & Sharing | |||
| Help! IR NEWB | Gaming | |||
| complete newb | Network & Sharing | |||
| NewB to Vista Mail has question | Vista mail | |||
| newb question - iteratate a hashtable | PowerShell | |||