awk splits file in to multiple - how to get filenames in variables withing ksh?

Hi all,

I'm using awk in a .ksh script to split one file by line prefix into different files (up to 4). The files are named after the prefix in the line, and a sequence no.
Is there any way to get the filenames in to variables too? I need _ftpfile1, _ftpfile2, _ftpfile3 and _ftpfile4 which are the results of the split from file _ftpfile.

Any ideas? Is this possible withing the awk? Or do I need to somehow search in the directory for the files?

Thanks,
Michael

awk '{close(f);f=$1}{print > f".txt"}' $_ftpfile
awk '{close(f);f=$1}{print > (f "_" FILENAME ".txt")}' $_ftpfile

But this only creates the split files with the original filename of the file splitted in the new filenames?

The result is the files as shown in the directory:

BND000000838_BHD000000838.TXT.3292379.txt
BDD000000838_BHD000000838.TXT.3292379.txt
BAD000000838_BHD000000838.TXT.3292379.txt

instead of

BND000000838.txt
BDD000000838.txt
BAD000000838.txt

which it was before?

What I need is the filenames assigned to a variable in the script, like

_ftpfile1 = BND000000838.txt
_ftpfile2 = BDD000000838.txt
_ftpfile3 = BAD000000838.txt

to be able to do further processing within the .ksh like preparing them for ftp transfer etc.