Ultimetly I'm trying to 3 arrays for like items and put those like items together by their color. But for now I'm just trying to check if one line in a array, $line, does not match anything in the other array, $colors,
$itemsofCars =@()
$cars = @()
$colors = Get-Content "C:\Newfolder\colors.txt"
$typefile = Get-Content "C:\Newfolder\cars_not_formatted.txt"
$carBlock = @("1")
foreach ($line in $typefile)
{
if($line.Contains("_Wheel") -or
$line.Contains("Doors") -or
$line.Contains("trunk") -or
$line.Contains("hood") -or
$line.Contains("coDriver") -or
$line.Contains("_driver")
)
{
$itemsofCars += $line
}
else
{
$cars += $line
}
}
#$itemsofCars
#$cars
#foreach ($car in $cars)
# {
# Add-Content 'C:\Newfolder\test.txt' $itemsofCars
# }
foreach ($line in $cars)
{
#trying to check if the line in car contains a color, if not then add to carBlock
if($line.ToUpper() -notcontains $colors.ToUpper())
{
#making sure there isn't duplicates
if($carBlock.ToUpper() -notcontains $car.ToUpper())
{
$carBlock = $line
$carBlock
}
}
else
{
}
}
this is a part of cars file
BRDM
BRDM_Wheel
BRDM_Doors_Driver
BRDM_Doors_coDriver
BRDM_Doors_hood
BRDM_Doors_trunk
BRDM_Doors_Driver_Woodland
BRDM_Doors_coDriver_Woodland
BRDM_Doors_hood_Woodland
BRDM_Doors_trunk_Woodland
BRDM_Doors_Driver_black
BRDM_Doors_coDriver_black
BRDM_Doors_hood_black
BRDM_Doors_trunk_black
BRDM_Doors_Driver_Pixel
BRDM_Doors_coDriver_Pixel
BRDM_Doors_hood_Pixel
BRDM_Doors_trunk_Pixel
BRDM_Doors_Driver_Camouflage
BRDM_Doors_coDriver_Camouflage
BRDM_Doors_hood_Camouflage
BRDM_Doors_trunk_Camouflage
BRDM_Doors_Driver_Flecktarn
BRDM_Doors_coDriver_Flecktarn
BRDM_Doors_hood_Flecktarn
BRDM_Doors_trunk_Flecktarn
BRDM_Woodland
BRDM_black
BRDM_Pixel
BRDM_Camouflage
BRDM_Flecktarn
This is the colors file
Woodland
Black
Pixel
Camouflage
Flecktarn
ZSU
Grey
Desert
Chrome
Winter
Scull
Blue
Orange
Red
Green
lightgreen
kamo
union
white
Gold
Samurai
grey
blue
kamo2
BIOHAZARD
CAMOgreen
carbon
Flora
GVILORD
skul
beige
chaki2
MCHS
les
umbr
I've rearranged the code numerus times and couldn't get it to work. What can I do to make it happen?