Create new files from UTF8 plain Text splitting with paragraph CR

Hi
I need to import in a File Maker Pro db the content of various files.
each file contains from 1 to 50 CR separated lines they all follow the very same structure.
I include one line as such where each line does not include spaces or any other symbol.

example
Filename 0052.txt
content of the file
520101 52 01 01 00:00:36:03 _DSC9439.MOV 19/7/2017 09:44:28 /Volumes/SHOWDOW_2017/OriginalClips B2A34529CFA6F17F
520102 52 01 02 00:00:36:12 _DSC9440.MOV 19/7/2017 09:46:34 /Volumes/SHOWDOW_2017/OriginalClips 8E1F97C4A1425D2C
520202 52 02 00 00:00:44:04 _DSC9441.MOV 19/7/2017 09:52:38 /Volumes/SHOWDOW_2017/OriginalClips 3D1002D1DD046171
520201 52 02 01 00:01:02:10 _DSC9442.MOV 19/7/2017 09:54:30 /Volumes/SHOWDOW_2017/OriginalClips 00148EABAEA7F886

The Script should name the new text file with the first word in each paragraph as such
SCNSEQTAKE.txt
520101.txt
520102.txt
520202.txt
520201.txt
and include each paragraph.

Then move to the next file where the structure is exactly the same, until every file in the folder is done

I have more than 2000 files and doing it manually is practically imossible
Thanks and regards

Model: MACPRO
Browser: Safari 537.36
Operating System: Mac OS X (10.10.5)

The following script will read tab separated files from Filemaker. Note that Filemaker does not pad a space before and after the tab as the data you provide does. So, I did not account for any spaces before or after the tab in this solution.

To use: First, select the file(s) you wish to convert. You can pick multiple files in the choose file dialog by holding down the command key and selecting the files. Second, select the folder where you want the converted file to be saved.


set tabFiles to (choose file with prompt "Select tab file..." of type {"txt"} with multiple selections allowed)
set saveFolder to (choose folder with prompt "Select folder to save results to:") as text

repeat with aFile in tabFiles
	set tabFile to aFile as text
	set tabRecords to read file tabFile using delimiter {return}
	set theData to tabRecords as text
	
	set fileName to (word 1 of first item of tabRecords) & ".txt" as text
	set theFile to saveFolder & fileName as text
	
	try
		set dataOut to open for access file theFile with write permission
		set eof of dataOut to 0
		write theData to dataOut starting at eof
		close access dataOut
	on error
		try
			close access file theFile
		end try
	end try
end repeat

on getItems(theRecord)
	copy the text item delimiters to origDelims
	set the text item delimiters to tab
	set recordItems to {}
	set recordItems to every text item of theRecord
	set the text item delimiters to origDelims
	return recordItems
end getItems

Browser: Firefox 50.0
Operating System: Mac OS X (10.10)