I want to check if I have .xml file first, if I have .xml file, the I have to check the .xml file existed, duplicated or not. For the example, I have those 3 file: ABC_123.xml ABC_456.PRO ABC_123.PRO
From those file, it means I have .xml
file (ABC_123.xml)
, then .xml
file is duplicted with this file ABC_123.PRO
. Then I have to continue to other process
.
I tried this, but it still return the result I have duplicate file, even I change the file name of .xml to DEF_123.xml
or other name with .xml extension.
for(;;)
{
$Path = "D:\SERVICE"
if(Test-Path -Path "$Path\*.xml")
{
Write-Host "XML exist"
$XML_File = Get-ChildItem -Name "$Path\*.xml"
$PRO_File = Get-ChildItem -Name "$Path\*.PRO"
if($XML_File.BaseName -eq $PRO_File.BaseName)
{
Write-Host "Duplicated"
Write-Host "Continue other process
}
else{
Write-Host "Not duplicate, process the xml file"
}
}
else{
Write-Host "XML not exist"
}
}