I am facing the following issue and I would really appreciate some help on that one.
I am automatically receiving 5 .csv files that I want to move to specific target folders. I want to only move them once I am certain that all of them are present. If one is missing, I don't want to move any of them. I tried the following code but the if statement is not working as expected. How can this be fixed?
$files = Get-ChildItem C:\directory -Filter *.csv
$filecheck = "C:\directory file.csv",
"C:\directory\file(1).csv",
"C:\directory\file(2).csv",
"C:\directory\file(3).csv",
"C:\directory\file(4).csv"
$result = ($filecheck | Test-Path) -notcontains $false
if($result = $true) {
{$_.Name -like 'file.csv'} {
$_ |Move-Item -Destination 'C:directory\targetFolder'
}
repeat for all files ...
}