Skip to content

Instantly share code, notes, and snippets.

@igarag
Created September 20, 2021 11:58
Show Gist options
  • Save igarag/2e75ab4cbe7fc2e0a3b09c26a97eaa94 to your computer and use it in GitHub Desktop.
Save igarag/2e75ab4cbe7fc2e0a3b09c26a97eaa94 to your computer and use it in GitHub Desktop.
Move n files from one directory to another.
# 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