I need to get only the nearest subdirectory and file name from the file path as follows.
Ex:-
(1)E:\Dump\DumpText-1.txt - Dump\DumpText-1.txt
(2)E:\Dump\SubDump1\DumpText-1.txt - SubDump1\DumpText-1.txt
(3)E:\Dump\SubDump3\Sub_SubDump1\DumpText-1.txt -Sub_SubDump1\DumpText-1.txt
My PowerShell Script as follows:
Get-ChildItem $directoryPath -Recurse | ForEach-Object -Process {if (!$_.PSIsContainer) {$_.FullName; $_.FullName -replace "^.*?\\"; " "}}