Last active
October 26, 2017 14:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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