Bull How to save a file with a filename based on a string in the file
Jan 07, 2010; 04:52
Bull
How to save a file with a filename based on a string in the file
I maintain html directories that consist of around a thousand records. Several directories share the same information, so updates require changing the data many times. I would like to make each record a separate file accessed by the directories via #bbinclude "filename". That way I make updates in one file, then use the Update tool on each directory. Clearly, if I cannot automate the creation of the record files, this will be a major undertaking and not worth any savings in effort that result.
Using AppleScript "record" I generated a script that highlights each record, copies the record, opens a new document, and pastes the record into it. The problem now is saving the file with a unique filename.
The records each have a unique five digit number that is easy to search for and copy (using grep). I'd like to use that number for the filename. However, when I record the actions that find the number, copy it, select "Save as", paste, add .html, and save, the script that is generated does not reflect the action of pasting. Instead the number that I selected and pasted during recording appears in the script as the number itself, meaning every file will (try to) have the same name, that of the file I used to record the script.
I have the feeling that when the "Save as" dialog box opens I am no longer talking to BBedit, but to the Finder. I tried recording a script of renaming a file (via Paste) in the Finder to see what that looks like, but the paste action is not recorded there either.
Any ideas on how to save a file with a filename based on a string in the file?
Thanks, Bull
Search
Lasso Programming
This site manages and broadcasts several email lists pertaining to Lasso Programming and technologies related and used by Lasso developers. Sign up today!