add script to merge folders
This commit is contained in:
parent
3af34b0064
commit
0379d33d8d
2 changed files with 23 additions and 0 deletions
22
scripts/merge.sh
Executable file
22
scripts/merge.sh
Executable file
|
@ -0,0 +1,22 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# author: Daniel Sommer <daniel.sommer@velvettear.de>
|
||||||
|
# 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"
|
|
@ -69,3 +69,4 @@ alias vim="nvim"
|
||||||
|
|
||||||
# scripts
|
# scripts
|
||||||
alias update="sudo $VELVETTEAR_DOTS/scripts/update.sh"
|
alias update="sudo $VELVETTEAR_DOTS/scripts/update.sh"
|
||||||
|
alias merge="$VELVETTEAR_DOTS/scripts/merge.sh"
|
||||||
|
|
Loading…
Reference in a new issue