Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, May 17, 2018 2:17 PM
I have the following two_line script:
$filenameFormat = "c:\temp\eds_file_list_" + (Get-Date -Format "yyyyMMdd_HHmmss") + ".txt"
get-childitem -Path y:\ -recurse -file > $filenameFormat
I'd like to be able to have it filter/modify the output so that block of files under directory headers, I get one record per file, with the fully qualified file name, with the file size, thus:
x:\dir1\dir2\file_01.txt 123456
x:\dir1\dir2\dir3\file_02.txt 654987
If it gets additional info like the time stamp, that is irrelevent, I can take it or leave it, but my end goal is at least fully qualified file name and size, in essentially a delimited text file.
All replies (2)
Thursday, May 17, 2018 2:44 PM ✅Answered
First you need to learn basic PowerSHell. Next learn to read the help for the CmdLets.
get-childitem -Pathy:\ -recurse -file | select Fullname, Length | Export-Csv file.csv
You cannot have sub=headers in a delimited file.
get-childitem -Pathy:\ -recurse -file | Format-Table -Group DirectoryName -Properties Fullname, Length
\(ツ)_/
Thursday, May 17, 2018 3:06 PM
Perfect. Thank you.
BTW, there was a typo on my OP, which made it misleading about the 'header' info. Instead of "modify the output so that block of files under directory headers" it should have read "modify the output so that instead of block of files under directory headers"