我只需要从文件路径中获取最近的子目录和文件名,如下所示。
前任:-
(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
我的 PowerShell 脚本如下:
Get-ChildItem $directoryPath -Recurse | ForEach-Object -Process {if (!$_.PSIsContainer) {$_.FullName; $_.FullName -replace "^.*?\\"; " "}}