FileNameDepth

WMA link


FileNameDepth["name"]

gives the number of path parts in the given filename.

← DirectoryQ
→ FileNameJoin