wasabi3689
asked on
file size
I want to get the file size for ".tif" file type in a directory including its sub-directories.
I want to get all the files whose size larger than 20MB each and all the files whose each between 10MB and 20MB
I want to get all the files whose size larger than 20MB each and all the files whose each between 10MB and 20MB
ASKER
Can you put an output result to a file? For example, 10-20MB size, this files and its directories, above 20Mb size the files and its directoires
So one file per size category?
Get-ChildItem C:\Temp -Filter *.tif -File -Recurse |
Select-Object -Property `
@{n='Category'; e={If ($_.Length -lt 10MB) {0} Else {If ($_.Length -lt 20MB) {1} Else {2}}}},
@{n='Size MB'; e={[math]::Round($_.Length / 1MB, 2)}},
Name,
DirectoryName |
Group-Object -Property Category |
ForEach-Object {$_.Group | Export-Csv -NoTypeInformation -Path "C:\Temp\TifSize_$($_.Name).csv"}
ASKER
I have this error in red
PS D:\NGProductionDocs\Config \Maintenan ce> .\FindFilePSbySize.PS1
Get-ChildItem : A parameter cannot be found that matches parameter name 'File'.
At D:\NGProductionDocs\Config \Maintenan ce\FindFil ePSbySize. PS1:1 char:79
+ Get-ChildItem F:\NGProductionDocs\NGSour ceDocs\ICS Storage -Filter *.tif -File <<<< -Recurse |
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic rosoft.Pow erShell.Co mmands.Get ChildItemC ommand
here is the script
PS D:\NGProductionDocs\Config
Get-ChildItem : A parameter cannot be found that matches parameter name 'File'.
At D:\NGProductionDocs\Config
+ Get-ChildItem F:\NGProductionDocs\NGSour
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Mic
here is the script
Get-ChildItem F:\NGProductionDocs\NGSourceDocs\ICSStorage -Filter *.tif -File -Recurse |
Select-Object -Property `
@{n='Category'; e={If ($_.Length -lt 20MB) {0} Else {If ($_.Length -lt 30MB) {1} Else {2}}}},
@{n='Size MB'; e={[math]::Round($_.Length / 1MB, 2)}},
Name,
DirectoryName |
Group-Object -Property Category |
ForEach-Object {$_.Group | Export-Csv -NoTypeInformation -Path "D:\NGProductionDocs\Config\Log\Misc\TifSize_$($_.Name).csv"}
With your filter, you can actually just remove the "-File" argument; I had that in for testing.
And you should seriously consider upgrading to at least PS 3.0. PS 2.0 dates back to 2006.
And you should seriously consider upgrading to at least PS 3.0. PS 2.0 dates back to 2006.
ASKER
Hi,
I have an output file something like this
"Category","Size MB","Name","DirectoryName"
"0","0.04","07834A47-82BF- 4186-A7D6- 1BB8B1E62E 5E.tif","F :\NGProduc tionDocs\N GSourceDoc s\ICSStora ge\2014\20 140101"
"0.04" means 0.04MB, correct?
I have an output file something like this
"Category","Size MB","Name","DirectoryName"
"0","0.04","07834A47-82BF-
"0.04" means 0.04MB, correct?
Yes.
ASKER
You have files names TifSize_0, TifSize_1, TifSize_02
what are they represented? why TifSize_0 has biggest size?
what are they represented? why TifSize_0 has biggest size?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window