oldBaseDir should be >= length to directory I think, and if bigger should have "/" at directory+oldBaseDir.length.

to avoid e.g. oldBaseDir = /a1/b1 matching directory = /a1/b1234 etc..