Instantly share code, notes, and snippets.

Embed
What would you like to do?
[combine folders] At one time, I had a need to combine files from multiple directories into one directory on a Mac. #obsolete
#!/bin/bash
dest="$(readlink -f "$1")"
shift
if [ ! -d "$dest" ]
then
echo "$dest is not a valid directory" >&2
exit 1
fi
sources=( )
while [ $# -gt 0 ]
do
new="$(readlink -f "$1")"
[ -d "$new" ] && sources=( "${sources[@]}" "$new" ) || echo "$new is not a valid directory"
shift
done
if [ ${#sources[@]} -eq 0 ]
then
echo "You didn't provide any valid source directories" >&2
exit 1
fi
cd "$dest"
find "${sources[@]}" -type f ! -path '*.Spotlight*' ! -name '.Trashes' ! -path '*.Trashes*' ! -name .fseventsd ! -path '*.fseventsd*' ! -name '.metadata*' ! -name '.com.apple*' -exec ln -vs {} \;
pwd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment