Use awk to create new folder in current directory

Alright, I am sure this is a laughable question, but I don't know so I am going to ask anyway.

I have a little script I am writing to take information from one source, recode it in a certain way, and print to files for each subject I have data for. This all works perfectly. I just want to put a little icing on the cake if you will and make is so no matter where I run the script, or on what computer, it will always send all of the output to a new folder in the current directory.

To be more specific. Lets say I am running the script in /home/research/.
Instead of sending the output to the current directory proper, I want to create a new folder to stuff it all in, so it is not intermingled with my other files. I travel a lot, so if I hardcode " > "iat_exp/" et "_" sn ".out", I get an error if the folder iat_exp does not exist yet.

So, I want my awk script to create that folder when it starts running.

I hope this is enough detail... I am an inexperienced scripter and am just using awk in cygwin on my xp laptop, although I am setting up my first Ubuntu box, so I am pretty excited about that.

Thanks all,
Chris

ROOT="iat_exp"
CMDmkdir="mkdir -p " ROOT " 2>/dev/null"
system(CMDmkdir)
close(CMDmkdir)
....
file=ROOT "/" et "_" sn ".out"
print "foo" > file
....
awk '{"mkdir iat_exp" | getline; print stuff}' inputfile > iat_exp/outputfile

thanks so much guys!

You can also make the directory in the BEGIN block

BEGIN {
    "mkdir iat_exp" | getline
}
{
   print ....
}

A better version that sends errors to /dev/null if the directory "iat_exp" already exists.

awk '{"mkdir iat_exp 2>&-" | getline;print stuff}' inputfile > iat_exp/outputfile

One more approch...by calling the system command

echo $a |awk '{system("mkdir directory");}'