How to transfer directories without their content

What I am trying to achieve is to transfer a directory block over sneakernet without having to include any of the content inside - it is assumed that the destination already has the content just missing the directory format.

I understand that directories are a hash containing the hashes of it’s files but clearly it contains a bit of additional information because ipfs ls and ipfs dag get shows filenames with it. ipfs block get gives me data but this data does not appear to correspond to the directory hash because when I pipe the data from ipfs block get to ipfs add I get a completely different hash. I could recreate the data as a block with the right hash but this isn’t much good to me unless I can add the raw block to the network (like ipfs add).

How does IPFS store directory data and how can I access the raw data without it trying to interpret it as a directory?

ipfs block get /ipfs/<folder> | ipfs dag put -f protobuf --input-enc protobuf

This doesn’t work in the new ipfs version 0.10.0 due to change in option flags. I tried with new flags ipfs block get /ipfs/<folder> | ipfs dag put --store-codec protobuf --input-codec protobuf but then I got Error: no decoder registered for multicodec code 80 (0x50).

Changing codec protobuf to dag-pb solved it.

ipfs block get /ipfs/<folder> | ipfs dag put --store-codec dag-pb --input-codec dag-pb

I ran this command and got error as below:

Error: protobuf: (PBLink) wrong wireType (5) for Hash

I’m not sure about the issue but perhaps ipfs ls --resolve-type=false --size=false /ipfs/<folder> works the same.

I’m not positive that I’m correct here but I think you might have problems with this if your directory contains a large number of entries and spans multiple blocks with HAMT.