adhoc handling of files and directories. Could use some code reuse love!