$newlocation = "/perl/ass/$folder[$N]/$logfiles[$hour]"; #### $newlocationdir = "/perl/ass/$folder[$N]"; #### use File::Path 'mkpath'; use File::Copy 'move'; mkpath "/perl/ass/$folder[$N]"; move($oldlocation, $newlocation) or die "File cannot be moved: $!";