Skip to content

Instantly share code, notes, and snippets.

@yamatt
Last active June 14, 2021 11:22
Show Gist options
  • Save yamatt/c6aafb43e85c08889e2577b5149d8f06 to your computer and use it in GitHub Desktop.
Save yamatt/c6aafb43e85c08889e2577b5149d8f06 to your computer and use it in GitHub Desktop.
Upload a bunch of files over time
#!/bin/bash
if [ -z "$1" ]; then
WD="$CWD"
else
WD="$1"
fi
readarray -d '' FILES < <(find $WD -type f -print0)
# iterate through array using a counter
for ((i=0; i<${#FILES[@]}; i++)); do
day=$(($i + 1))
FILE_PATH="${FILES[$i]}"
FILE_NAME=$(basename "$FILE_PATH")
echo b2 upload-file bucket \""$FILE_PATH"\" \""$FILE_NAME"\" | at 1am + $day days
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment