Command Detail - B

basename

A rough PowerShell equivalent for the unix basename is:

dir <whatever> | select name

This depends on the file actually existing, whereas basename doesn't care.

A more precise (but perhaps less concise) alternative[1] is:

Notes [1] I found [System.IO.Path]::GetFileName after reading Power Tips of the Day - Useful Path Manipulations Shortcuts, which has some other useful commands

Last updated