On 3/7/07, Nicolai Amter <[EMAIL PROTECTED]> wrote:

I can export out two text files from WC which I'll clean up in Excel and
then save as a Tab or Comma Delimited file.
One will be in the format will be Name, Location, Account, Password and
the other will be Product Name, Owner Name, Serial Number, Comments.

I know enough about Applescript and programming that I should be able to
change where the data get imported into if you or somebody could write a
example script.

Hi, Nicolai.

Here is a script that ought to do the job or at least get it started.
You can use it to import tab delimited lists of passwords or serial
numbers as described above. Hopefully it is clear enough to modify or
extend to suit your purposes, but if not please let me know. I've
tested it successfully with some simple examples but it doesn't do
much real error checking so I can't promise it'll handle everything.

Incidentally I suppose it would not be hard to make this script import
other Yojimbo data types from tab delimited files. I leave that as an
exercise for the reader!

Be well,
Jim

set _type to button returned of (display alert "Select what kind of
data to import to Yojimbo:" buttons {"Cancel", "Serial Numbers",
"Passwords"} cancel button 1)
if _type is "Cancel" or _type is "" then
        return
end if

-- read the file
set _file to choose file with prompt "Select a tab delimited file
containing " & _type
open for access _file
set _data to read _file using delimiter {(ASCII character 13), (ASCII
character 10)}
close access _file

-- import each line as a tab delimited record
-- per http://www.blankreb.com/studiosnips.php?ID=17
set _delim to AppleScript's text item delimiters
set AppleScript's text item delimiters to tab -- or {","}
repeat with _index from 1 to count of _data
        try
                set _line to the text items of item _index of _data
                if _type is "Passwords" then
                        -- items are name, location, account, and password
                        MakePassword(item 1 of _line, item 2 of _line, item 3 
of _line,
item 4 of _line)
                else if _type is "Serial Numbers" then
                        -- items are product, owner, serial number, and comments
                        MakeSerial(item 1 of _line, item 2 of _line, item 3 of 
_line, item
4 of _line)
                end if
        end try
end repeat
set AppleScript's text item delimiters to _delim

on MakePassword(_name, _location, _account, _password)
        tell application "Yojimbo"
                set _new to make new password item with properties {name:_name,
location:_location, account:_account, password:_password}
        end tell
end MakePassword

on MakeSerial(_product, _owner, _number, _comments)
        tell application "Yojimbo"
                set _new to make new serial number item with properties
{name:_product, owner name:_owner, serial number:_number,
comments:_comments}
        end tell
end MakeSerial

--
------------------------------------------------------------------
This message is sent to you because you are subscribed to
 the mailing list <[email protected]>.
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
List archives:  <http://www.listsearch.com/yojimbotalk.lasso>
Have a feature request, or not sure if the software's working correctly? Please send mail to: <[EMAIL PROTECTED]>

Reply via email to