I am working on the sceond part of a move script and I am very close to a solution. I have one small stumbling block in an otherwise complete script.
I am sure this script can be condensed to make it more efficient but:
$move = $sourceDir + "\" + $_.fileName
$csv | % {
if ($_.folder -eq 'Y')
{
$move = $sourceDir + "\" + $_.fileName
mi $_ "$move"
}
mi $_ "$move"
} #end for
The problem I have is that I need the initial move folder declared as the first value of the csv fileName colomn as it will always be a Y for the folder colomn which determines if the file is moved to that folder or the last one which had a carresponding Y.
The if statement will update the $move variable to the new move folder if present otherwise it will just keep the move folder as the last iteration and move it to that folder.
I am unsure how to reference the first value in the csv i have tried to reference it as an array fileName[1] but it did not work.
Im hopeful it is a small fix.
Thanks for taking the time to look at this.
Craig.
Get the value with the following:
In this example, ‘fileName’ is the column name in the CSV file for which we want to grab the first value ($csv[0]).
Hope this helps.