I have some file with different extension. Like this files
file123_A1.que
file456_B2.que
file123_00_A1.pro
file890_11_C2.pro
I want to copy the file by lastwritetime. But I don't want to copy the file if the file already has .pro, even the file is the lastwritetime.
For the example, after sort the file by lastwritetime, the file that will be copied is file123_A1.que , but the that file name already has .pro by identify the 2 last file name A1. So in this case, I need to copy the other file.
My expectation I will not copy a file if the file has the same 2 last name with different extension file (ex: file123_A1.que and file123_00_A1.pro the same 2 last file name. I will not copy this file file123_A1.que)
Anyone can give idea please. Thank you I tried this
$Sel_JobFolder = "D:\601"
$JobFolder = @(Get-ChildItem "$Sel_JobFolder\*.que" | Sort-Object LastWriteTime)[0] |
ForEach-Object { Copy-Item -path $_.FullName -destination .\ -force}