Skip to content

Instantly share code, notes, and snippets.

@KhasMek
Created January 25, 2014 17:04
Show Gist options
  • Select an option

  • Save KhasMek/8619591 to your computer and use it in GitHub Desktop.

Select an option

Save KhasMek/8619591 to your computer and use it in GitHub Desktop.
BASH:pull memes
#!/bin/bash
# A script to keep my fucking meme downloads somewhat manageable
# The goal of this script is to comm two dirs (one on my android
# device and the other locally, then sort the new files into a new
# folder to then be uploaded to $social_network. Maybe a final option to
# move the images to the old folder after the upload is complete
# would be good too. And remvoing of (1) files.)
#
# TODO: Make not so ghetto
root_dir=`pwd`
old_dir=$root_dir/posted_memes
sort_dir=$root_dir/to_sort
post_dir=$root_dir/new_memes_to_post
pull_dirs=
if [ ! -d $old_dir ]; then
mkdir $old_dir
fi
if [ ! -d $sort_dir ]; then
mkdir $sort_dir
fi
if [ -d $post_dir ]; then
mv "$post_dir/*.*" $old_dir
else
mkdir $post_dir
fi
cd $sort_dir
echo "pulling $pull_dirs from your device..."
cd $root_dir
echo "comparing $sort_dir with $old_dir.."
comm -2 -3 <(ls $sort_dir) <(ls $old_dir) | while read line; do
mv $sort_dir/$line $post_dir
done
number=`ls -l $post_dir | wc -l`
echo "$number new images ready to be posted in $post_dir"
# Nuke the dups && cleanup
echo rm -rf $sort_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment