I am working on a small portion of a larger scripting solution in which i need to create folders based on values stored in a CSV and then move the applicable files in to the new folder according to values in a column of the csv.
The format of the CSV:
fileName, folder
AC002 Y
AC034 Y
AC001
X2400 Y
AC006
AC007
AC009 Y
This is the code I have working for the problem:
$sourceDir = read-host "Please enter source Dir:"
$csv = import-csv C:\scripts\files\files.csv
$csv | where {$_.folder -eq 'Y'} | % {
$path = $sourceDir + "\" + $_.fileName
if(-not (Test-Path $path))
{
md $path
}#end if
}#end for
The next step will probably be a bit more tricky.
Thanks to Shay Levy for the help,
Craig
Try this, it will create the folder even if it exists. We can change that if you want and create only folders that do not exist: