I have recovered files and currently they have this structure:
root/MD5_of_file1/file1 root/MD5_of_file2/file2 ... root/MD5_of_filen/filen Obviously, duplicates are now in the same folder. The filename contains no information, just the block number at which it was found during the recovery.
I want to flatten the structure, keeping only one file for each MD5. How could I do this efficiently ?
Just to be clear, here are some actual data:
feceee0fc150d191c5fd48ca6acee2f6 feceee0fc150d191c5fd48ca6acee2f6/f225407559.odt feceee0fc150d191c5fd48ca6acee2f6/f94654911.odt e905bb0a76c0055a2be1b8285d39c715 e905bb0a76c0055a2be1b8285d39c715/f0702423.odt e905bb0a76c0055a2be1b8285d39c715/f26479232.odt e905bb0a76c0055a2be1b8285d39c715/f3084695.odt I want to flatten to something like this:
f225407559.odt f0702423.odt but there are no guarantees that filenames are distinct. Files could easily be renamed to the corresponding MD5 of their content, which is already computed, as it is the name of the folder in which they currently are.
ls root/MD5_of_file1/file* | grep -v 'root/MD5_of_file1/file1' | while read f ; do rm "$f" ; done