Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@goodevilgenius
Last active October 26, 2017 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goodevilgenius/5544686 to your computer and use it in GitHub Desktop.
Save goodevilgenius/5544686 to your computer and use it in GitHub Desktop.
[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