Skip to content

Instantly share code, notes, and snippets.

@scorpp
Last active August 29, 2015 13:56
Show Gist options
  • Save scorpp/9207503 to your computer and use it in GitHub Desktop.
Save scorpp/9207503 to your computer and use it in GitHub Desktop.
Find all java files in current directory and move them in maven-correct directory with git
find . -type f -name '*.java' | \
while read f; do \
target=$(grep '^package ' $f | sed -e 's/package \+//' -e 's/;$//' -e 's/\./\//g'); \
newf="src/main/java/${target}/$(basename $f)"; \
mkdir -p $(dirname $newf); \
git mv $f $newf; \
chmod 644 $newf; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment