I'm looking for help to create a script to: 1- check if 3 files are located in a given directory 2- for the files that are older than the current date they will be moved to a archive directory and the start-proce3ss will call out a third-party process to run and create the files 3- for all missing files the script will start-process to run a third-party process to run and create files.
I am not familiar to array and the script I've been working on runs a IF method to validate every step so I've been thinking the Array would make it simpler.
# script
$report = "C:\Reports"
$archive = "C:\Reports\Archive"
$scripts = "C:\Scripts"
# check 1.txt#
$file = "C:\Reports\1.txt"
if (-not(Test-Path -Path $file -Path Type Leaf)) {
try {
cd $scripts
start-process Third-party.bat
}
catch {
}
}
# check 2.txt#
$file = "C:\Reports\2.txt"
if (-not(Test-Path -Path $file -Path Type Leaf)) {
try {
cd $scripts
start-process Third-party.bat
}
catch {
}
}
# check 3.txt#
$file = "C:\Reports\3.txt"
if (-not(Test-Path -Path $file -Path Type Leaf)) {
try {
cd $scripts
start-process Third-party.bat
}
catch {
}
}