RISL2023
RISL2023

Reputation: 137

Powershell: Extract all file names from a directory and input them into a textbox

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)

Upvotes: 1

Views: 118

Answers (1)

mklement0
mklement0

Reputation: 439058

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:

Upvotes: 1

Related Questions