Last active
August 29, 2015 14:10
-
-
Save dereksz/6f3bac9c753051f120d3 to your computer and use it in GitHub Desktop.
Reorganizing files in directory tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create relative sha1 deep files | |
sha1deep -rel . | tee sha1deep.log | |
# Create missing dirs referenced in a SHA1sum file | |
sed -re 's/^[0-9a-f]+\s+//;s!/[^/]*$!!' SD.log | sort -u | xargs -I{} mkdir -p "{}" | |
# Take two md5deep checksum files and re-arrange one directory based on the other | |
join -j1 <(sed -re 's/ +/ "/;s/$/"/' 1.4Tb.log | sort) <(sed -re 's/ +/ "/;s/$/"/' SD.log | sort) | | |
sed -re 's/^[0-9a-f]+/mv -v /' | | |
bash | |
# Remove all empty directories | |
find -depth -type d -exec rmdir {} \; | |
# Building a SHA1 forrest - se look at all of the SHA1's and build a directly based on the unique set of the first 4 characters | |
cut -b1-4 ../SD.log | sort -u | xargs mkdir /p | |
# Link to originals | |
sed -re 's!./!"../!;s!$!"!;s!^([0-9a-f]{4})!\1/\1!;s!^([0-9a-z/]+) +(.*)$!ln \2 \1!' ../SD.log | bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment