Skip to content

Instantly share code, notes, and snippets.

@tuukkao
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuukkao/d05636f68578b91a2969 to your computer and use it in GitHub Desktop.
Save tuukkao/d05636f68578b91a2969 to your computer and use it in GitHub Desktop.
#!/bin/sh
#Change this to point to your dropbox shared folder
dest_path=''
#Change this if there's a naming conflict
temp_path=_$1
#The GNU find expression for matching and removing files
find_expression='-name *.orig -delete -o -name *.exe -delete'
#The final path that consists of dest_path and the given directory
final_path=$dest_path/$1
#Check paths before going further
if [ -z "$1" ]; then
echo Please give a path to copy.
exit 1
elif [ ! -d "$dest_path" ]; then
echo The destination doesn\'t exist or is not specified.
exit 1
fi
echo Copying $1 into $temp_path...
cp -r $1 $temp_path
echo Removing unnecessary files...
find $temp_path -type f $find_expression
echo Copying to the destination path...
if [ ! -d "$final_path" ]; then mkdir "$final_path"; fi
cp -r -u $temp_path/* "$final_path"
rm -r $temp_path
echo Done.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment