I have a powershell script that I run to produce a folder listing & size file text file. I give it a root folder to start in & it goes thru each folder recursively summing up the file sizes within the folder.
The end result is like this:
Myfolder|5800
Bin|1800
|de|40000
|en|50000
||Random1|5043
||Random2|5044
Data|33000
|Cache|20000
|||TE9|221000
||||TF9|20000
and so on.
Anything without a pipe "|" to it's left is considered a subfolder off the root folder. Anything with a pipe to it's left, is a subfolder of the folder above it. 2 pipes = 2 levels, 3 pipes = 3 levels and so on. I bring it into Excel by saying it is a delimited text file.
The issue is is that the folder total is for only the files in that folder & not the total of the folders below it. In the above example:
Bin|1800
|de|40000
|en|50000
||Random1|5043
||Random2|5044
beginning in cell A1
A1 & B1 = Bin & 1800 respectively.
B2 & C2 = de & 40000 respectively (A2 is blank)
B3 & C3 = en & 50000 respectively (A3 is blank)
C4 & D4 = Random1 & 5043 respectively (A4 & B4 are blank)
C5 & D5 = Random2 & 5044 respectively (A5 & B5 are blank)
the 1800 in B1 is the total of the files in the Bin folder off the root folder. The total of 40000 in C2 is the total of the de sub folder. The total of the en subfolder would be 50000 (C3) + 5043 (D4) + 5044 (D5) = 60087.
What I need to do is to be able to sum the right-most columns, rolling them up & adding them to the end of the row at the next folder level above them. Using the above example, 10087 would be the total in D3. The total in cell C1 would be 40000 (C2) + 50000 (C3) + 5043 (D4) + 5044 (D5) = 100087. I could then add the 1800 (B1) to that total & get the total file size for the Bin folder & all its subfolders.
I would like to be able replicate that anywhere along the way - where I have numbers in 2 adjacent columns to add them & come up with a folder size from that point no matter where I am within that folder structure.
As far as the data is concerned, a blank in a column implies it is a subfolder of the folder above it. And, I know that the last 2 columns of any row will always be the folder name & the folder size. There are no set number of columns, but I think it runs to 10 or 12 now. There are between 20,000 & 30,000 rows at any given time.
I thought subtotals might work, but with up to a dozen of them, that might not be readable. Too, it's the reverse of the problem of totaling off the end - having to replicate data down & not overwrite something.
Is there any good way to do this?
The end result is like this:
Myfolder|5800
Bin|1800
|de|40000
|en|50000
||Random1|5043
||Random2|5044
Data|33000
|Cache|20000
|||TE9|221000
||||TF9|20000
and so on.
Anything without a pipe "|" to it's left is considered a subfolder off the root folder. Anything with a pipe to it's left, is a subfolder of the folder above it. 2 pipes = 2 levels, 3 pipes = 3 levels and so on. I bring it into Excel by saying it is a delimited text file.
The issue is is that the folder total is for only the files in that folder & not the total of the folders below it. In the above example:
Bin|1800
|de|40000
|en|50000
||Random1|5043
||Random2|5044
beginning in cell A1
A1 & B1 = Bin & 1800 respectively.
B2 & C2 = de & 40000 respectively (A2 is blank)
B3 & C3 = en & 50000 respectively (A3 is blank)
C4 & D4 = Random1 & 5043 respectively (A4 & B4 are blank)
C5 & D5 = Random2 & 5044 respectively (A5 & B5 are blank)
the 1800 in B1 is the total of the files in the Bin folder off the root folder. The total of 40000 in C2 is the total of the de sub folder. The total of the en subfolder would be 50000 (C3) + 5043 (D4) + 5044 (D5) = 60087.
What I need to do is to be able to sum the right-most columns, rolling them up & adding them to the end of the row at the next folder level above them. Using the above example, 10087 would be the total in D3. The total in cell C1 would be 40000 (C2) + 50000 (C3) + 5043 (D4) + 5044 (D5) = 100087. I could then add the 1800 (B1) to that total & get the total file size for the Bin folder & all its subfolders.
I would like to be able replicate that anywhere along the way - where I have numbers in 2 adjacent columns to add them & come up with a folder size from that point no matter where I am within that folder structure.
As far as the data is concerned, a blank in a column implies it is a subfolder of the folder above it. And, I know that the last 2 columns of any row will always be the folder name & the folder size. There are no set number of columns, but I think it runs to 10 or 12 now. There are between 20,000 & 30,000 rows at any given time.
I thought subtotals might work, but with up to a dozen of them, that might not be readable. Too, it's the reverse of the problem of totaling off the end - having to replicate data down & not overwrite something.
Is there any good way to do this?