Does someone have a script to append text to multiple documents at once? For instance, if I want to append the same block of text to 50 .txt or .rtf documents in my database.
I’m not aware of such a script but several questions come to my mind first:
-
What’s the origin of the text to append? E.g. clipboard or currently selected text?
-
What kind of documents do you use?
-
How does the script find the documents to which the text should be added? Or just use the selected items?
While doing that for .txt files would be straightforward (after the questions raised by @cgrunenberg have been answered), appending text to RTFs would be a lot more complicated, given their structure and the fact that the content is styled, which simple text is not.
Actually it’s a lot easier since version 3, just use constructions like…
tell application id "DNtp"
tell text of selected record 0
make new paragraph with data (return & "The text to append") at end
end tell
end tell
What attributes will this new paragraph have? I have no experience with RTF at all. Therefore, I’m wondering if
- there’s something like a default style
- the style of the preceding paragraph will be applied
- something else entirely?
Seem to be the default attributes of the text engine in this example.
That’s why I thought that it might be a tad more complicated: depending on the RTF document, that new paragraph might look out of place. Anyway, as long as the OP doesn’t tell us what they want…
Christian,
Answers to your questions above:
- Appended text could be either clipboard or via a dialogue box to input it. I don’t really care, just some way to get a text appended.
- I was thinking of TXT or RTF, but if I could just do this with TXT that would be fine for my purposes.
- Selected items is what I was thinking.
What I am trying to do is that I archive quotes from Kindle books into my database, each quote becomes it’s own document. I want to add the name of the author and book to the bottom of each document. I have a script to do this in the Comments field, but I’d prefer it be right in the text of the document.
I don’t have much in the way of AppleScript skills. I might be able to hack this together by borrowing parts of scripts and lots of trial and error, but perhaps someone with actual scripting skills could create this more quickly. Thanks.
Oh, and while I’m requesting scripts:
A script to break a Sheet into individual TXT documents (one document per record) would be nice. Right now I do it by converting the Sheet to a paginated PDF, then converting that PDF to TXT. Works, but is kind of round-about. The Kindle Notes export sends me a CSV file which is the source of the Sheet.
Do you have a sample CSV file to share?
Record 0?
Of course 1
Haha! I was thinking you had yet another card up your sleeve I didn’t know about