make the script work on OS X
fixes #687
Merge pull request #756 from vladak/osx

make the script work on OS X
destroy pool for renamed files handling properly