Trying to do a regex match and replace for a specific pattern to rename files. Unfortunately I'm not very good using regex and would appreciate any help you can offer.
the pattern I'm looking to replace is.
(Conflicted copy * )
To explain I need to replace (Conflicted copy *) basically everything that matches the words "(Conflicted copy" pattern and anything between those words and the closing parentheses.
so for example. Book1 (Conflicted copy some junk here).xls to : Book1.xls
What regex would I use for that? To replace?
I've tried the following: pattern = "\([^\(]*\)";
Unfortunately that doesn't work as there are paths that have () in them.
(ie, C:\Some crap\1.(stuff)\book1 (Conflicted copy junk stuff).xls )
it will fail and rename the file to:
(C:\Some crap\1.\book1.xls) -> then error out because that path doesn't exist.
Any help would be greatly appreciated thank you guys.
\(Conflicted copy [^)]*\)probably will work.