Last active
March 19, 2022 13:43
-
-
Save jeremy-rutman/b6fe2aaef94e2b09d0625f46a9df9a57 to your computer and use it in GitHub Desktop.
get e.g. all .jpgs in a dir and subdirs, copy or delete them
This file contains hidden or 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
# sed 's\.*/\\' cuts anything before the final forward slash , leaving filename without path | |
for f in $(find . -name '*.jpg'); do echo $f;echo $f|sed 's\.*/\\' ;cp $f $(echo $f|sed 's|.*/||'); done | |
#or e.g. only .jpgs larger than 10k and put in specific dir | |
for f in $(find /path/to/dirwithsubdirs/ -name '*mark.png' -size +10k ); do echo $f;echo $f|sed 's|.*/||' ;cp $f /path/to/destiny/data_logos/$(echo $f|sed 's\.*/\\'); done | |
#dont clobber extant files, by using cp --backup=numbered | |
for f in $(find /path/to/dir -name '*.jpg'); do cp --backup=numbered $f pics/$(echo $f|sed 's|.*/||'); done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment