Created
October 9, 2017 17:26
-
-
Save imaizume/4c70a8a63e93fa43f0c1722aca512616 to your computer and use it in GitHub Desktop.
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
#!/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