TUTORIAL IPFS - retrieving pins' hash and batch importing

in ipfs •  7 years ago  (edited)

Let's say that you have some pinned files on your IPFS node but also no idea of their hash.

You can retrieve the list of files by executing this simple command:

ipfs pin ls

ipfs-pin-ls.png

but far too many hashes will be printed out!

at this point you start saying yourself something like: "there must be a better way!" and indeed there is:

ipfs pin ls --t=recursive

ipfs-pin-ls-recursive.png

okay, now you want to send all these hashes to someone, save them on your hashbook, send them to someone... but all these lines have a part that is, well repetitive! So you want to cut that "recursive" text out! So, supposing you are on Linux like me and you are using bash, this will serve you well!

ipfs pin ls --t=recursive | sed 's/ recursive//'

ipfs-pin-ls-recursive-cut.png

and this will save the output to an easily shareable file:

ipfs pin ls --t=recursive | sed 's/ recursive//' > my_pins_collection.txt

perfect! But let's say that you have thousands of pins! having this file you surely can run ipfs pin add {{hash}} but it will take you, well... too much, better spendable, time! so here this while loop will help you to pin all the files on the file you just created:

while read hashline; do
    ipfs pin add "$hashline";
    done < my_pins_collection.txt

and that's all!

Now your pins are importing on your friend's computer, on your backup server, on your colleague's work folder... anyway it is destinated!

HAPPY SHARING! ;D

donation area: http://fgobbo.com/donate (it helps me to keep servers running ipfs nodes)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!