Hi,
I want to move from Slipbox to Yojimbo. Both only use .rtf and rtfd formats. (My needs are fairly simple, if those two won’t do, I’ll try Freeform.) I’ll be moving about 3000 notes. The categories (Keywords) in Slipbox are all exported in the last line of the text content. I want to turn these Keywords into Tags for Yojimbo.
I have worked everything out to get the line from each item containing all the Keywords, I just need to extract them and create a variable for each one. Here’s the part of my script (derived from here) that gets me the line containing the Keywords.
set theSourceFile to choose file of class {"public.rtf"}
tell application "TextEdit"
open theSourceFile # REQUIRED
tell (get front document)
set searchString to "Keywords: "
set tc to count paragraphs
set start_Line to 1 -- the starting line of the first portion
considering case
repeat with i from 1 to tc
if ((get paragraph i) = searchString) or i = tc then
set keyLine to paragraph i as text
end if
end repeat
end considering
end tell
end tell
Here are a couple of examples of what that returns.
(.rtf 1)
Keywords: Media, Sound and Music, Software Help
(.rtf 2)
Keywords: Access, Personal, Private
(.rtf 3)
Keywords: Hardware, Wishlist
Can you help me manipulate the text so that I can assign those keywords to variables in order to set the tags in Yojimbo? (I have everything worked out except extracting the keywords, of which there are normally no more than 3-8 for each exported Slipbox file.) Please note that some of the Keywords consist of more than one word, the words of which are always separated by one space. (Yojimbo accepts tags of multi-word phrases also.)
For the three examples above the variables will be something like this:
(item 1)
set key1 to “Media”
set key2 to “Sound and Music”
set key3 to “Software Help”
(item 2)
set key1 to “Access”
set key2 to “Personal”
set key3 to “Private”
(item 3)
set key1 to “Hardware”
set key2 to “Wishlist”
I need (to summarize) to remove "Keywords: " from the paragraph, get the next string before the comma, keep doing that until I get the string after the last occurrence of ", ", etc. I figured on feeding it to grep or perl or something in one or more “do shell script” constructs. I’m not that great with regex, though.
Thanks for your help.
L. Lee