Created
September 20, 2021 11:58
-
-
Save igarag/2e75ab4cbe7fc2e0a3b09c26a97eaa94 to your computer and use it in GitHub Desktop.
Move n files from one directory to another.
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
# Move n files from one directory to another. | |
# Useful for separating datasets in train/val | |
# that do not have code implemented in the training itself. | |
#!/bin/bash | |
i=0 | |
j=$(stat source_folder/* --printf "%i\n" | wc -l ) | |
NUM_FILES=314 | |
for k in source_folder/*; do | |
if (( (j - ++i) < $NUM_FILES )); then | |
echo mv -v -- "$k" ~/target_folder # Test it first with echo, then remove echo to actually move the files. | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment