awk check if folder exist

Hello
Im trying to build a script that (among other stuff) checks each line in a file for the $4 "variabel" and if there are a folder in the directory that has that not has the same name as that it create a folder, otherwise it wont do anything. I guess i could just send the errors to /dev/null, but it would cool to fix it without.

this is what i have tried with (among many other similar stuff)

{
if (system("test -d" $4) ) {
system("mkdir" $4) }
}
else
system("mkdir " $4)
}

With the -p option of mkdir it's not necessary to check the existance of a directory, have a read of your man page.

#!/bin/nawk -f

function isdir(s) {
  return !system("test -d \""s"\"");
}

{
  print "Directory [" $0 "]: " ((isdir($0))? "exists":"doesn't exist")
}