Skip to content

Instantly share code, notes, and snippets.

@imaizume
Created October 9, 2017 17:26
Show Gist options
  • Save imaizume/4c70a8a63e93fa43f0c1722aca512616 to your computer and use it in GitHub Desktop.
Save imaizume/4c70a8a63e93fa43f0c1722aca512616 to your computer and use it in GitHub Desktop.
#!/bin/bash
IFS_bak=$IFS
IFS=$'\n'
s3_movies=($(aws s3 ls --profile=s3-admin s3://private.imaizu.me/movies/ | awk '{print $4 " " $5}'))
local_movies=($(ls -1 *.mp4))
archive_dir=${HOME}/Desktop/archived_movies/
for s in "${s3_movies[@]}"; do
for l in "${local_movies[@]}"; do
if [ "${s}" == "" ] || [ "${l}" == "" ]; then
continue
fi
if [ "${s}" == "${l}" ]; then
mv "${l}" "${archive_dir}"
echo "Moved ${l}, it's already backed-up to s3 bucket!"
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment