I have a directory of pdf
files all named differently for example
SOR001.pdf SOR002.pdf SOR003.pdf
is it possible to extract just the Basename
and input that information to a textbox
in visual studio. the format i am looking for would be like this (SOR001,SOR002,SOR003)
CodePudding user response:
To get a string like (SOR001,SOR002,SOR003)
:
'({0})' -f ((Get-ChildItem *.pdf).BaseName -join ',')
To get a string like ('SOR001','SOR002','SOR003')
:
'({0})' -f ((Get-ChildItem *.pdf).BaseName.ForEach({ "'$_'" }) -join ',')
See also:
-f
, the format operator-join
, the string joining operator