BTW, you had two errors in this line. First is A-z instead of A-Z. Second is that [^.lnk] will match any *one* character which is not one of ".lnk". I suppose you wanted to check that the pattern does not end in ".lnk", but not sure why. IMO, you should check if the given path is a file or folder somewhere else.