Applescript to pre-process some input files?
I am working on an idea to process some files before importing them into FM 11.
There are some text data files that need to be searched. They are relational, using an ID field in each file. The record separator is a "$". Yes, a dollar sign. Not common, and FM doesn't import that very well. So I want to change that dollar sign. I am planning on using Unix command "tr" to do that job; works great and very quickly (about 3 seconds to process 640,000 lines!).
To make this easier, however, I want to activate that command from within FileMaker. This would be easier for other users who may not be familiar with a terminal window. I also want to implement a way for the user to browse for a directory and pick the files to operate on. (New files will be periodically created and will need to be processed again; they are downloaded Zip files and so could conceivably be placed anywhere. I am trying to think of ways to make this as simple and idiot proof as possible.) Once they choose the files, it would fire the "tr" command to process them, and then import them into the DB. The field mapping SHOULD remain fixed and I am not trying to design around making that flexible. :)
It seems that Applescript is the best way to do this. Or at least interface with the shell to run the "tr" command. And perhaps do the file picking. I am thinking that the Applescript interface to Finder would be able to return a list of files, but how to get an interface where the user gets to pick the directory?
Is this all possible? Is my approach off base? Are there simple Applesscript steps that work on multiple files at once, without having to resort to loops? The Applescript documentation for FM11 doesn't seem terribly robust.
Any suggestions would be welcomed.