Correct POSIX issues in function
managing conflicts
slight change in function arguement SaveDir to Dir