The below PowerShell command will display the size of each text files within a folder.
foreach ($f in ChildItem -Path E:\text *.txt) {$f.name + ":" + $f.length}
As you can see I am using the ‘foreach’ statement of PowerShell to loop through each text file within a folder in your computer and prints out their name and file size accordingly.
hello.txt:37
There is only one file in the folder which is a text file.