Last active
September 15, 2018 21:56
-
-
Save pavgup/00e211fda40167752dbe017c46870d9b to your computer and use it in GitHub Desktop.
Moving all jpegs to a single directory
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
### The first line simply moves the files using their existing filenames, if there is a complex tree structure with the same filenames, you overrwrite fies | |
find . -type f -exec file --mime-type {} \; | awk '{if ($NF == "image/jpeg") {split($0,a,":"); print a[1]}}' | xargs -I{} cp '{}' /Users/pavan/Dental/all-images | |
### The second line adds complexity by grabbing random strings and dropping renaming the copied files randomly: | |
find . -type f -exec file --mime-type {} \; | awk '{if ($NF == "image/jpeg") {split($0,a,":"); print a[1]}}' | xargs -I{} sh -c 'cp "{}" /Users/pavan/Dental/all-images/$(cat /dev/urandom | env LC_CTYPE=C tr -cd 'a-f0-9' | head -c 64).jpg' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment