Skip to content

Instantly share code, notes, and snippets.

@mrl22
Created November 3, 2024 16:31
Show Gist options
  • Save mrl22/e6592bbdac360716be7964dbdf709ac1 to your computer and use it in GitHub Desktop.
Save mrl22/e6592bbdac360716be7964dbdf709ac1 to your computer and use it in GitHub Desktop.
Multithreaded recursive upload to dropbox using dbxcli with resume
# Uploads everything in the current directory to Dropbox UPLOAD directory (change line 7)
# Configured for 2 threads, any more and you get api throttling errors
find . -type f -print0 | xargs -0 -n 1 -P 2 -I {} sh -c '
file="{}"
log_file="uploaded_files.log"
dropbox_path="UPLOAD${file#.}"
# Check if file is already in log
if grep -qxF "$file" "$log_file"; then
echo "Skipping already uploaded file: $file"
else
# Echo and upload, then log the file on success
echo "dbxcli put \"$file\" \"$dropbox_path\""
if dbxcli put "$file" "$dropbox_path"; then
echo "$file" >> "$log_file"
else
echo "Failed to upload: $file" >&2
fi
fi
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment