I have a PowerShell script that will get a list of all the files in a folder, and then (based on regular expression matches inside the Switch statement) will move each file to the specified folder (depending on the regular expression matching).
I have a problem with a specific list. A group of files (PDF files named after their part number) that start with "40" are moved to the specified folder.
The expression itself is just enough for me, the problem is that if the file contains _ol OR _ol_ , then it cannot be a match.
For example, the file names below should match:
401234567.pdf 401234567a.pdf 401234567_a.pdf 401234567a_something.pdf
The below below should NOT match:
401234567_ol.pdf 401234567_ol_something.pdf
Using the regex ^(?i)40\w+[^_ol].pdf$ is the closest I can get. He will deny 401234567_ol.pdf as a coincidence; however, it accepts 401234567_ol_something.pdf . Does anyone know how I can deny this as a coincidence?
Lost source share