0

For example:

I have 2 folders: one and two.

What is the command or script to do the following tasks:

  • Check sha256sum of all files in one (and its subfolders). Then write their checksums in one.txt.
  • Check sha256sum of all files in two (and its subfolders). Then write their paths and their checksums in two.txt.
  • For each checksum in one.txt, find it in two.txt. If that checksum exists in two.txt, then rename the file in two with that checksum. (fullfilename becomes fullfilename.dupdupdup)
0

This should work if you don't have newlines in the file names:

grep \
-f <(find one -type f -exec sha256sum {} + | awk '{print $1}') \
<(find two -type f -not -name "*.dupdupdup" -exec sha256sum {} +) \
| cut -c 67- \
| xargs -I{} mv {} {}.dupdupdup
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy