0

Sorry i am newbie. i only know how to copy/move/delete files using powershell. it will be really helpful if someone can help me in this matter and please excuse my english.

I have multiple sub folders, lets say

C:\test\1
C:\test\2
C:\test\3

inside the folder there is multiple image files. i want to list the sub folder's file name and size and save text files inside the subfolders.

C:\test\1\filelist.txt
C:\test\2\filelist.txt
C:\test\3\filelist.txt

filelist.txt will have something like this

Image1.png  30kb
Image2.png 4MB

Here is a sample script i found from online but i need it to save text file in subfolders based on subfolder file names.

$Folder = 'C:\pic'
$Output = 'C:\output.txt'
$Files = Get-ChildItem -Path $Folder -Filter *.png -File
$objShell = New-Object -ComObject Shell.Application
$objFolder = $objShell.Namespace($Folder)
foreach( $File in $Files ) {
    $objFile = $objFolder.ParseName($File)
    $Name = $objFolder.GetDetailsOf($objFile, 0)
    $Size = $objFolder.GetDetailsOf($objFile, 1)
    $Length = $objFolder.GetDetailsOf($objFile, 27)
    $Tab = [char]9
    "$Name$Tab$Size$Tab$Length" | Out-File -Append -FilePath $Output
}

```
Shahpari
  • 115
  • 2
  • 8
  • Try this: https://stackoverflow.com/questions/1153819/get-list-of-files-recursively-by-bit-rate-in-powershell – SebC May 04 '23 at 16:35

1 Answers1

1

If you want to use a built application for this, I recommend: https://www.karenware.com/powertools/karens-directory-printer

No Body
  • 11
  • 2