我有powershell脚本,我想使用wile card ex.sqlfile*\table i get childitems-recurse返回基于位置的多个文件夹。谢谢您
edqdpe6u1#
“我要返回最后一个子文件夹末尾的最新和最后一个文件。”基于你的上述评论,这就是你想要的吗?
Get-ChildItem -Recurse -Path D:\Temp -Directory # Results <# Directory: D:\Temp Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 06-May-20 20:30 AddressFiles d----- 17-Feb-20 15:50 est d----- 14-Mar-20 17:03 here d----- 26-May-20 10:38 hold d----- 06-May-20 20:30 LogFiles d----- 06-Feb-20 14:56 NewFolder d----- 12-Feb-20 14:24 ParentFolder d----- 03-Feb-20 11:55 Reference d----- 06-Feb-20 14:56 Source d----- 24-Feb-20 22:03 Target d----- 22-May-20 20:51 Zips Directory: D:\Temp\NewFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 03-Feb-20 11:55 New folder d----- 20-Jan-20 11:17 temp Directory: D:\Temp\ParentFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 12-Feb-20 14:08 ChildFolder Directory: D:\Temp\ParentFolder\ChildFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 12-Feb-20 14:08 GrandchildFolder # > Get-ChildItem -Recurse -Path D:\Temp -Directory | Select-Object -Last 1 # Results <# Directory: D:\Temp\ParentFolder\ChildFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 12-Feb-20 14:08 GrandchildFolder # > (Get-ChildItem -Recurse -Path D:\Temp -Directory | Select-Object -Last 1).Fullname # Results <# D:\Temp\ParentFolder\ChildFolder\GrandchildFolder # > $LastSubFolder = (Get-ChildItem -Recurse -Path D:\Temp -Directory | Select-Object -Last 1).Fullname Get-ChildItem -Path $LastSubFolder # Results <# Directory: D:\Temp\ParentFolder\ChildFolder\GrandchildFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 28-Aug-07 13:08 2646058 GrandchildThumperLong.wav -a---- 28-Aug-07 13:05 683670 GrandchildThumperShort.wav -a---- 23-Apr-99 18:22 668440 GrandchildWELCOM98.WAV # > Get-ChildItem -Path $LastSubFolder | Sort-Object -Property LastWriteTime # Results <# Directory: D:\Temp\ParentFolder\ChildFolder\GrandchildFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 23-Apr-99 18:22 668440 GrandchildWELCOM98.WAV -a---- 28-Aug-07 13:05 683670 GrandchildThumperShort.wav -a---- 28-Aug-07 13:08 2646058 GrandchildThumperLong.wav # > Get-ChildItem -Path $LastSubFolder | Sort-Object -Property LastWriteTime | Select-Object -First 1 -Last 1 # Results <# Directory: D:\Temp\ParentFolder\ChildFolder\GrandchildFolder Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 23-Apr-99 18:22 668440 GrandchildWELCOM98.WAV -a---- 28-Aug-07 13:08 2646058 GrandchildThumperLong.wav # >
1条答案
按热度按时间edqdpe6u1#
“我要返回最后一个子文件夹末尾的最新和最后一个文件。”
基于你的上述评论,这就是你想要的吗?