rmv closer to mv behavior

This commit is contained in:
q
2014-02-17 19:07:01 +02:00
parent 1dd0198435
commit c705e549f3

View File

@@ -190,7 +190,14 @@ function gcd() {
function rmv () {
#mv with rsync
rsync -vaP --remove-source-files "$@"
local sources
sources=()
for (( i=1; i<=$(($#-1)); i++ ))
do if [ -d "${!i}" ]
then sources+=("${!i%/}")
fi
done
rsync -vaP --remove-source-files "${sources[@]}" "${@: -1}"
# remove empty folders from sources (not last argument)
for (( i=1; i<=$(($#-1)); i++ ))
do if [ -d "${!i}" ]