use File::Path; rmtree(['/foo/bar/baz', $directory2],0,1);