split-hunks: allow non-empty dir

Add ability to set output directory and allow non-empty directories. Due to
this, the perl rename script has been replaced by a loop that checks whether
the file is not already suffixed with a .patch extension.