How can I wrap existing files in a directory from the command line?

I know I can wrap files in a directory when I use “ipfs add”. However, when I have already added files with “ipfs add”, is there some way I can create a directory out of the list of the resulting hashes?

Yes, it just isn’t in a very discoverable place. You need the object sub-section for this:

~$ ipfs object patch add-link --help
...
  Example:

  $ EMPTY_DIR=$(ipfs object new unixfs-dir)
  $ BAR=$(echo "bar" | ipfs add -q)
  $ ipfs object patch $EMPTY_DIR add-link foo $BAR
  
  This takes an empty directory, and adds a link named 'foo' under it, pointing
  to a file containing 'bar', and returns the hash of the new object.

So create a directory with pinned objects?

-Sent from my iPhone; sorry for ayn typos.

see How can attach cid to new node