Skip to content

Instantly share code, notes, and snippets.

@rindeal
Created October 21, 2016 23:59
Show Gist options
  • Save rindeal/4d1dc34a3febf431704b3addd06cb815 to your computer and use it in GitHub Desktop.
Save rindeal/4d1dc34a3febf431704b3addd06cb815 to your computer and use it in GitHub Desktop.
mv-merge.sh
#!/bin/bash
DEST="${@:${#@}}"
ABS_DEST="$(cd "$(dirname "$DEST")"; pwd)/$(basename "$DEST")"
for SRC in ${@:1:$((${#@} -1))}; do (
cd "$SRC";
find . -type d -exec mkdir -p "${ABS_DEST}"/\{} \;
find . -type f -exec mv -u \{} "${ABS_DEST}"/\{} \;
find . -type d -empty -delete
) done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment