Join two folders?

How would you add a normal folder to an ipfs folder

Can you give an example of what you mean by an ā€œipfs folderā€ and what you mean by a ā€œnormal folderā€?

HASH FOLDER2 + ipfs add -r /FOLDER1

Iā€™m not sure thereā€™s a single command that will do this easily.

But hereā€™s a simple proof of concept script that will do this.

Assuming HASH is the hash of a folder in IPFS, this script will loop through the contents of a local folder named test2 and add the contents to the existing directory hash. The final hash thatā€™s spit out by the script is the hash of the combined directory.

#!/bin/bash

# hash of folder currently in IPFS
HASH="QmW85q9pmby55reZb9YrcLRr5L2gHcvTFGoSmjADCbhq1w"

FOLDER2="./test2"

for item in "$FOLDER2"/*; do
	tempname="$(basename "$item")"
	temphash="$(ipfs add --pin=false -r -Q "$FOLDER2"/"$tempname")"
	HASH=$(ipfs object patch add-link $HASH "$tempname" "$temphash" )
done

echo $HASH
1 Like

ipfs object patch add-link; this command can combine HASHFOLDER + REGULAR FILE, should be easy to add hashfolder+ folder functionality or even hashfolder+hashfolder

Yeah, that seems like it would be a reasonable enhancement to merge the links from two IPFS directories.

so off to github we go

1 Like