Created
September 1, 2018 10:20
-
-
Save nik-hil/eb5f1b2b2b9983dfa653fd3df9d4a0b7 to your computer and use it in GitHub Desktop.
bash script to shuffle and copy
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
https://unix.stackexchange.com/a/217720 | |
shuf -zn<count> -e *.<file_ext_in_curnt_dir> | xargs -0 cp -vt <target_dir> | |
shuf -zn8 -e *.jpg | xargs -0 cp -vt target/ | |
shuf shuffles the list of *.jpg files in the current directory. | |
-z is to zero-terminate each line, so that files with special characters are treated correctly. | |
-n8 exits shuf after 8 files. | |
xargs -0 reads the input delimited by a null character (from shuf -z) and runs cp. | |
-v is to print every copy verbosely. | |
-t is to specify the target directory. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://stackoverflow.com/a/12978830/618018
Use python to shuffle