Supernewbie problems

Hi from Taiwan,
I need to split a long text file in several smaller ones. Each paragraph should become a new independent file.
I Use Tex edit and through the automatic functions of script Editor I am able to cut the first paragraph, open a new file, paste it, select the first word in the new file as I need to use that name for the newly created filename. Yet as, the dialog to save the new file, appears I have to manually paste the content of the clipboard and manually close the new file after saving it.
Is tere a way to split and save each paragraph of my superlong file in separate docs automatically?
Thank you really

Dante

There are many threads on this topic. This is a very common mistake of people just learning AppleScript. You don’t need to use external applications to read and write files, AppleScript can handle it all on its own. If the file isn’t ridiculously large, the following script should work. You can save it as an application and then just drop the source text file on the application icon in the Finder. If the file is enormous, then you may need to read the file itself in chunks to avoid a stack overflow. Try this first and if it doesn’t work, then we’ll explore reading the file a bit at a time.

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]

Thank you very much Jon. Your script works pèrfectly and generat ed 12784 files in a few minutes. However the file name are : name 00001 and so on. In fact I am creating a database of movies and infos and they contain fields both In English and Chinese. I need to call each file with the first name on each paragraph.
Do you think this can be achieved in some ways? the original file is a tab delimited file, and the newfilename should be fropm the beginnig of each paragraph till the frist tab marks in the paragraph.

Regards and thanks

Dante

No problem. This revised script will extract the name from each paragraph up to the tab. It will also make sure that each file name is unique in case that file name already exists by appending a sequential number to the end of the name:

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]