Stationery and stationery scripts
I have a question about stationery and stationery scripts.
It can best be illustrated by an example.
Say I want to create a project folder, and within that a text file describing the project. I can set that up as stationery, using a folder ProjectStationery and within it a text file ProjectDescription.txt
If invoked, it would create a literal copy of the folder and file at the current location in EagleFiler.
If I wanted to customize the name, say to Project-154, I could employ a stationery script. Within this would be a metadata handler, which receives as a parameter an AppleScript record with information on the current context. Based on this, and perhaps the current date or prompted information, the handler returns an AppleScript record which will be used to set the EagleFiler metadata on the file. So I can customize the folder name, title, and tags: ProjectStationery becomes Project-154.
But say I wanted the text file to also have a custom name and content. This raises some questions.
Question 1: Does the instance of the stationery exist at the time the handler is run?
If so, I could simply rename the text file and append text to it as needed. If not, I’d be out of luck.
But it raises another question.
Question 2: Does renaming a file here (by script) violate EagleFiler’s rules?
The file would be renamed within EagleFiler, but not by EagleFiler, so would EagleFiler pick up the change?
You might get around this by using the script to create the file in the first place. EagleFiler could pick up a newly created file.
Finally, a third question.
Question 3: The _context
parameter to the metadata handler includes the path to the library and the immediate folder name within the library, but not the path to that folder. How would you know where to create a file?
As an aside, there is a typo in the documentation of 7.3 under “Stationery Script Details”: the record key libraryPath is misspelled “libaryPath”.