Test-Path
noun
say it: “TEST PATH” /ˈtɛst ˈpæθ/
A PowerShell command that answers True if a file or folder is there and False if it isn't, with no error for a missing one.
What does Test-Path do?
Test-Path answers one question, whether something is there: True or False, with no error for a missing file. -PathType Leaf asks "is it a file?" and -PathType Container "is it a folder?", and a wildcard asks "is anything like this there?". Check first, then act.
Test-Path trip-photos.zip # True
Test-Path passport.pdf # False
In a sentence
- “Test-Path answered False for passport.pdf, and no red error appeared.”
- “Before packing, the script used Test-Path to check that the outbox folder was there.”
Level: Novice · More PowerShell terms at this level
Updated