Skip to content

Instantly share code, notes, and snippets.

@sambatyon
Created May 30, 2014 07:26
Show Gist options
  • Save sambatyon/c27da6b2754f8067041a to your computer and use it in GitHub Desktop.
Save sambatyon/c27da6b2754f8067041a to your computer and use it in GitHub Desktop.
Extract Headers from folder keeping structure
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: extractheaders src dest"
exit
fi
orig_dir=`pwd`
origin=$1
if [[ "$1" = /* ]]; then
origin=$1
else
origin=`pwd`/$1
fi
if [[ "$2" = /* ]]; then
destination=$2
else
destination=`pwd`/$2
fi
rsync -a -f"+ */" -f"- *" "$origin/" "$destination"
cd "$destination"
for vcd in $(find -type d -a \( -name ".svn" -o -name ".git" \)); do
rm -rf "$vcd"
done
cd "$origin"
for f in $(find -name "*.h" -o -name "*.hpp" -o -name "*.hxx" -o -name "*.hh" -o -name "*.ixx" -o -name "*.ipp" -o -name "*.inc"); do
cp "$f" "$destination/$f"
done
cd "$destination"
find . -type d -empty -delete
cd "$orig_dir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment