Yep i was using the previous code , $files instead of $folder

Its working now but its giving the full location , needed the foldername only but it might be possible to use the full location as well in the script , will have to mess with it a bit

Thanks again for your help