I want to check .jpg file in the 2nd folder. 2nd folder has some subfolder. if .jpg exist in the subfolder of 2nd folder, I will copy a file from 1st folder to subfolde
Assuming that I understood your question correctly and you want to replace existing JPEG files in the "Process" folder if they have a corresponding PNG file in the "Initial" folder, the following should do the trick:
$L_Name = 15
Get-ChildItem -Path "$JobError\*\*.jpg" | ForEach-Object {
$basename = $_.BaseName.Substring($L_Name)
$png = "$JobInit\${basename}.png"
if (Test-Path $png) {
$timestamp = Get-Date -Format 'yyyyMMddhhmmss'
$dst = Join-Path $_.DirectoryName "${timestamp}_${basename}.jpg"
Copy-Item $png $dst -Force
}
}