I have recovered files and currently they have this structure:root/MD5_of_file1/file1root/MD5_of_file2/file2...root/MD5_of_filen/filenObviously, 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:feceee0fc150d191c5fd48ca6acee2f6feceee0fc150d191c5fd48ca6acee2f6/f225407559.odtfeceee0fc150d191c5fd48ca6acee2f6/f94654911.odte905bb0a76c0055a2be1b8285d39c715e905bb0a76c0055a2be1b8285d39c715/f0702423.odte905bb0a76c0055a2be1b8285d39c715/f26479232.odte905bb0a76c0055a2be1b8285d39c715/f3084695.odtI want to flatten to something like this:f225407559.odtf0702423.odtbut 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.
How to keep exactly one file in a directory?
shell script;files;scripting;rename