Merge branch 'master' of bitbucket.org:/ambrevar/home-config
commit
e71c2ed917
|
@ -0,0 +1,41 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$1" = "-h" ] || [ $# -lt 2 ]; then
|
||||
cat <<EOF
|
||||
${0##*/} FOLDERS DEST
|
||||
|
||||
Move FOLDERS into DEST. Does not overwrite by default. Empty folders are ignored.
|
||||
|
||||
Options:
|
||||
-f: overwrite destination.
|
||||
EOF
|
||||
exit
|
||||
fi
|
||||
|
||||
OPT_OVERWRITE=false
|
||||
if [ "$1" = "-f" ]; then
|
||||
OPT_OVERWRITE=true
|
||||
shift
|
||||
fi
|
||||
|
||||
for i; do
|
||||
ARGLIST="${ARGLIST:+$ARGLIST\n}$i"
|
||||
done
|
||||
FOLDERS="$(echo $ARGLIST | head -n-1)"
|
||||
DEST="$(echo $ARGLIST | tail -n1)"
|
||||
|
||||
while read -r FOLDER; do
|
||||
while read -r FILE; do
|
||||
DESTFILE="$DEST/$FILE"
|
||||
if [ ! -e "$DESTFILE" ] || $OPT_OVERWRITE; then
|
||||
mkdir -p "$(dirname "$DESTFILE")"
|
||||
mv -v "$FOLDER/../$FILE" "$DESTFILE"
|
||||
fi
|
||||
|
||||
## We switch to FOLDER so that 'find' strips the parent dirs from the path.
|
||||
done <<EOF
|
||||
$(cd "$FOLDER/.." && find "$(basename ${FOLDER})" -type f)
|
||||
EOF
|
||||
done <<EOF
|
||||
$(echo "$FOLDERS")
|
||||
EOF
|
|
@ -1,10 +1,10 @@
|
|||
#!/bin/sh
|
||||
## This is a compatibility wrapper for 'realpath'.
|
||||
|
||||
if [ -z "$(command -v greadlink)" ]
|
||||
if [ -n "$(command -v greadlink)" ]; then
|
||||
## On BSD systems, we might have greadlink
|
||||
greadlink -f "$@"
|
||||
elif [ -z "$(command -v readlink)" ] && [ "$(uname)" = "Linux" ]
|
||||
elif [ -n "$(command -v readlink)" ] && [ "$(uname)" = "Linux" ]; then
|
||||
readlink -f "$@"
|
||||
else
|
||||
## Dirty fallback
|
||||
|
|
Loading…
Reference in New Issue