How can I recursively add files that are created after a specific date?

Assume I have folder has multiples files under it that are created on different date.
I want to add files that are created after specific date. Is it possible using ipfs add -r? not adding completed folder but folder with having files that are created after a specific date.

IPFS is not adding files “twice”. If you are worried about that :slight_smile: If the file has not been modified, it will use the same hash and will not be duplicated.

In case instead you want to do something more specific and clean the old files you can use find to do that:

cp -R ./original ./new
find ./new/ -mtime +6h #do this to print all the files older than 6h
# once you validated that you like what you will delete, you can run:
find ./new/ -mtime +6h -delete # this will delete them
ipfs add -r ./new
rm -rf ./new

I hope this is helpful

1 Like

=> So peerA share a file and peerB gets the file through IPFS. Then when peerB uploads the same file into IPFS it won’t be uploaded since its already on the IPFS ?

For example I downloaded source code of a program, and I saved the date. After executing of the code, it will generate output files. Under the same directory I just want to push files that are generated as output after that specific date which will ignore the source code file.

tar , zip has options for users to zip files after a specific date. But I guess since already uploaded file won’t uploaded again into IPFS its not necessary.

=> Is there any other solution without deleting the files that are generated before the specific date? If the folder is large like 1 GB, its inefficient to copy it into another folder and follow your solution.

You don’t need to copy it if you have no problem in re-adding the files. Note that IPFS will copy the files anyway into the repository so that if the file is deleted, it can serve it anyway.

A note: you usually don’t upload anything. It is just stored into your IPFS repo so that if somebody requests the hashes, your node will send them. In any way, your IPFS repo will notify the other nodes that you have those hashes.

I would suggest anyway to not copy, to not delete, but instead add the new files with a wrapper. in IPFS you will not have duplicates of the files as long as they have the same hash/content.