Import output of `op list items --account ACCOUNT2 | op get item -` to a different account
Using 1Password command-line tool 1.12.4.
I’ve got temporary access to a vault in ACCOUNT2 so that I can copy the entries to ACCOUNT1. They didn’t set up my account permissions to have right-click "copy item" support so that I could do this in the GUI, so I exported everything using op:
op list items --account ACCOUNT2 | op get item - > ACCOUNT2.jsonl
I did the same thing (more or less) with op list documents (there are two attached documents).
I’ve split the individual line entries into multiple single JSON files and want to create them in the new account more or less like this:
op create item --account ACCOUNT1 --vault VAULTNAME --template item1.json
This didn’t work initially because of the missing category.
So I modified it:
op create item --account ACCOUNT1 --vault VAULTNAME --template item1.json Password
This worked, but not really. It was imported as "Untitled Password", despite the fact that there is a details.title field.
So I decided to try something else:
jq '{
notesPlain: .details.notesPlain,
password: (.details.fields[] | select(.type == "P") | .value),
title: .overview.title
}' <item1.json | op create item --vault VAULTNAME --account ACCOUNT1 --template - Password
Which didn’t work because template doesn’t know how to deal with - as a name, so I changed it again:
jq '{
notesPlain: .details.notesPlain,
password: (.details.fields[] | select(.type == "P") | .value),
title: .overview.title
}' <item1.json > x.json && op create item --vault VAULTNAME --account ACCOUNT1 --template x.json Password
And that still imported it as "Untitled Password".
As it looks right now, I’m probably going to have to make a script that not only transforms the target file as the jq does above, but creates another script that will run op create item --vault VAULTNAME --account ACCOUNT1 --template x.json Password --title $title.
Is there no easier way? It seems to me that the output of op get item should be fully compatible with op create item, even if op create item ignores things like uuid, vault, etc.
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: macOS 12.2
