diff --git a/scripts/merge.sh b/scripts/merge.sh new file mode 100755 index 0000000..3963460 --- /dev/null +++ b/scripts/merge.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh + +# author: Daniel Sommer +# license: MIT + +# merge files from two folders and cleanup the source + +# get and check variables +[[ -z "$1" ]] && printf "error: no source directory specified!\n" >&2 && exit 1 +[[ -z "$2" ]] && printf "error: no destination directory specified!\n" >&2 && exit 1 +source="$(realpath $1)" +destination="$(realpath $2)" + +[[ ! -d "$source" ]] && printf "error: source '"$source"' is not a valid or existing directory!\n" >&2 && exit 1 +[[ ! -d "$destination" ]] && printf "error: destination '"$destination"' is not a valid or existing directory!\n" >&2 && exit 1 + +printf ">> merging directory '"$source"' into '"$destination"' with rsync...\n" + +rsync -avh --remove-source-files --progress "$source/" "$destination" +find "$source" -mindepth 1 -type d -empty -delete + +printf ">> merge finished after "$SECONDS" seconds!\n" diff --git a/zsh/zprofile b/zsh/zprofile index a00476f..8363c23 100755 --- a/zsh/zprofile +++ b/zsh/zprofile @@ -69,3 +69,4 @@ alias vim="nvim" # scripts alias update="sudo $VELVETTEAR_DOTS/scripts/update.sh" +alias merge="$VELVETTEAR_DOTS/scripts/merge.sh"