Created
April 30, 2020 04:09
-
-
Save computercam/e294b20cd16fe4c868d0634e6a6a5071 to your computer and use it in GitHub Desktop.
ext4magic recover text files
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
# Recover files from ext4magic based on the path to the missing textfile | |
# After running ext4magic -m /path/to/device, from the directory containing RECOVERDIR, run this script with the path to the directory containing text files you want to recover. | |
# Example: | |
# ext4magic_recover_text.sh /home/cameron/lostfiles | |
function get_timestamp() { | |
date -d @${1} | cut -d' ' -f1-6 | sed 's/ /_/g' | |
} | |
for file in $(grep -Rl $1 ./RECOVERDIR/ 2> /dev/null) | |
do | |
filename=$(grep "^file://$1" $file | cut -d' ' -f1 | cut -d/ -f7- | sed 's/\//-/g') | |
timestamp=$(grep "^file://$1" $file | cut -d'"' -f3 | cut -d':' -f2 | cut -d, -f1) | |
if [[ -n "$filename" && "$filename" != "Binary" ]] | |
then | |
timestamp=$(get_timestamp $timestamp) | |
filename="$filename-$timestamp" | |
cp -f $file ./${filename} | |
else | |
cp -f $file ./ | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment