Alistoffilepathswhich're *relative to* 'WorkingDir' Folder, every item in the list can be pointing to File (doesn'tendwith'\')orDirectory(endswith'\')orNone-ExistingFile/Directory.
Calls'Invoke-Preprocessing'functionusingNamedParamters,with'WorkingDir'(MandatoryParameter)which's used as the base folder when searching for files recursively (using 'Get-ChildItem'), other two paramters are, in order from right to left, the Optional 'ExcludeFiles', which can be a path to a file, folder, or pattern-matched (like '*.png'), and the 'ProgressStatusMessage', which'susedinProgressBar.
SameasExampleNo.1,butuses'-SkipExcludedFilesValidation',which'll skip the validation step for 'ExcludedFiles' list. This can be useful when 'ExcludedFiles' list is generated from another function, or from unreliable source (you can'tguaranteeeveryiteminlistisavalidpath),butyouwanttosilentlycontinuethroughthefunction.
throw"[Invoke-Preprocessing] Invalid Paramter Value for 'WorkingDir', passed value: '$WorkingDir'. Either the path is a File or Non-Existing/Invlid, please double check your code."
throw"[Invoke-Preprocessing] One or more File Paths & File Patterns were not found, you can use '-SkipExcludedFilesValidation' switch to skip this check, and the failed files are: $failedFilesList"
throw"[Invoke-Preprocessing] Found 0 Files to Preprocess inside 'WorkingDir' Directory and '-ThrowExceptionOnEmptyFilesList' Switch is provided, value of 'WorkingDir': '$WorkingDir'."
}else{
return# Do an early return, there's nothing else to do
}
}
for($i=0;$i-lt$numOfFiles;$i++){
$file=$files[$i]
# If the file is in Exclude List, don't proceed to check/modify said file.
$fileIsExcluded=$False
for($j=0;$j-lt$excludedFiles.Count;$j++){
$excluded=$excludedFiles[$j]
$strToCompare=($excluded)-replace('^\.\\','')
if($file.FullName.Contains("$strToCompare")){
$fileIsExcluded=$True
break
}
}
if($fileIsExcluded){
continue
}
# TODO:
# make more formatting rules, and document them in WinUtil Official Documentation