mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 8e163d1822ea8eb64eb09222472afadd8971f192
parent 8e58b8992d9d85421309951365941072c2691dc4
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Sun, 11 Dec 2016 22:47:23 +0100

updir

Diffstat:
updir | 29+++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)

diff --git a/updir b/updir @@ -0,0 +1,29 @@ +#!/bin/bash + +# copy all contents of $1 on $2 +# giving unique name to directories +# and put stuff in cache + +# hardcoded list of exclusions +EXCLUDE='--exclude="papers/**" --exclude="wikipedia/**"' + +set -x +set -e + +FOLDER="$1" +DEST="$2" +shift +shift + +cd "$FOLDER" +# copy files to destination +rsync -avzPy --progress --backup --exclude="cache/**" --exclude="papers/**" --exclude="wikipedia/**" ./ "$DEST" + +# move files to cache +# TODO: this is inefficient and should be done with mv invocations +# use, e.g., http://unix.stackexchange.com/a/155633/8446 +rsync -avzPy --remove-source-files --exclude="cache/**" --exclude="papers/**" --exclude="wikipedia/**" $EXCLUDE ./ "cache/" + +# now, remove remaining empty directories +find ./ -type d -empty -exec rmdir '{}' + +