Last active
April 9, 2017 15:36
-
-
Save xdevs23/b37510335175c7e1f03300f4247d9a74 to your computer and use it in GitHub Desktop.
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
# Copies files that have a specific extension to another directory while keeping directory structure and remove the prefix | |
# Example: ./dir_00000032.chk/Media/Backgrounds/Indoors/hall.jpg -> ../recov/jpg/Media/Backgrounds/Indoors/hall.jpg | |
# Replace the extension as you like | |
find -name "*.jpg" -type f -print0 | xargs -0 -i bash -c 'tt="$(echo -n '"'"'{}'"'"' | sed -e '"'"'s/[.]\/[^/]*\///g'"'"')"; mkdir -p "../recov/jpg/$(dirname '"\""'$tt'"\""')"; cp -v '"'"'{}'"'"' "../recov/jpg/$tt"' | |
# To remove the extension completely and just copy everything: | |
find -type f -print0 | xargs -0 -i bash -c 'tt="$(echo -n '"'"'{}'"'"' | sed -e '"'"'s/[.]\/[^/]*\///g'"'"')"; mkdir -p "../recov/$(dirname '"\""'$tt'"\""')"; cp -v '"'"'{}'"'"' "../recov/$tt"' | |
# Of course replace the things as you like | |
# This comes extremely useful when you have found.* folders from chkdsk which you want to extract | |
# files from. | |
# Other examples | |
# Copy music | |
find -type f \( -name "*.mp3" -o -name "*.mp2" -o -name "*.ogg" -o -name "*.flac" -o -name "*.wav" -o -name "*.aac" \) -print0 | xargs -0 -i bash -c 'tt="$(echo -n '"'"'{}'"'"' | sed -e '"'"'s/[.]\/[^/]*\///g'"'"')"; mkdir -p "../recov/music/$(dirname '"\""'$tt'"\""')"; cp -v '"'"'{}'"'"' "../recov/music/$tt"' | |
# Copy images | |
find -type f \( -name "*.png" -o -name "*.tif" -o -name "*.tiff" -o -name "*.gif" -o -name "*.tga" -o -name "*.pdn" \) -print0 | xargs -0 -i bash -c 'tt="$(echo -n '"'"'{}'"'"' | sed -e '"'"'s/[.]\/[^/]*\///g'"'"')"; mkdir -p "../recov/images/$(dirname '"\""'$tt'"\""')"; cp -v '"'"'{}'"'"' "../recov/images/$tt"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment