PowerShell – Easy Way to Manipulate Parts of a FileName

Scenario:  You want to use PowerShell to extract parts of the following filename:   C:temp123.csv



$f =  “C:temp123.csv”

[io.fileinfo] $f | % Basename     #Result:  123.csv

[io.fileinfo] $f | % Extension      #Result:   .csv

[io.fileinfo] $f | % Name        #Result:      123.csv

[io.fileinfo] $f | % DirectoryName      #Result:    C:temp

[io.fileinfo] $f | % FullName   #Result:   C:temp123.csv



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: