The mv command in Unix has some subtlety to it in that
it either moves or renames the file in question (never mind that it
uses rename(2)
to do it), but that subtlety is a good thing in that mv
usually does what you expect it to do.
Not so with IntelliJ. I use IntelliJ for Java development, and while I do occasionally dally with Eclipse or Netbeans, I always come back. Anyway, with a bunch of packages to rearrange across a multi-module project, I tried using the "move" refactor, e.g., to change com.foo.x to com.foo.y. Contrary to my expectations, this produces com.foo.y.x, but not noticing immediately, I ended up with goofy package names like com.bar.impl.impl.impl. ((in classic Monty Python falsetto) That doesn't have much impl in it...) Grrrr.
A little commandline action will get things cleaned up in terms of file layout, e.g.:
find src -type file \
| sed -E '{h;G;s:\n: :;s/(impl\/)+/(impl\/)/;}' \
| xargs -n 2 mv
The first part of the sed program is a recipe for echoing the input as the first hunk of the line.

Add a comment.









