Don't forget the /s modifier on your regex, because a file name could actually contain a newline character (at least on unix-like platforms that's allowed).
Comment on Re^2: How do i take the first 4 characters of any file name in a specified directory?