Fixed duplicating bug, now works for files

Needs more testing (No rights and Linux/OSX)