Can anyone assist with correcting my KRename regex?

I'm trying to rename a bunch of files by removing all parenthetical from the file name EXCEPT if they contain a specific word.

For instance, say these are my files:

  • File 1 (Boop) (Ver 1).file
  • File 1 (Beep) (Ver 2).file
  • File 2 (Soup).file
  • Another File (Seep).file
  • Yet Another (Ver 5).file

I want to KEEP any parenthetical with "Ver" and a number, but I want the rest gone.

So it should look like:

  • File 1 (Ver 1).file
  • File 1 (Ver 2).file
  • File 2.file
  • Another File.file
  • Yet Another (Ver 5).file

I can write \(.*\) for Find and leave Replace blank to get rid of anything parenthetical, and it works great.

So I tried \((?!Ver).*\) and a bunch of alternatives, but it gives me the same result of just removing all parentheticals (even the ones I want). I have tried lookaheads, lookbehinds, and a bunch of syntax tweaks, but I always either end up with no parentheticals or all of them.

Any suggestions?

Edit: I got it working (kinda). I couldn't make it work with the wildcard thing, but after changing it to \((?!Ver)\w+\), it did work except if there were more parenthetical after. Like if it was "File (Ver 9) (Extra Junk).file", then it would just leave it untouched. So I had to use a combo of two expressions to clean up the rest.

maxwellfire,

I think you want something like s*(((?!versd).)*)s*

See regexr.com/7jbvk

Basically this consumes all characters between parentheticals with whitespace unless the next character set in the parentheticals is ver followed by a number. Now this uses a negative lookahead which might not be supported by the engine that krename is using. You can also explicitly construct the group to not match, but that’s rather painful, see here

  • All
  • Subscribed
  • Moderated
  • Favorites
  • kde@lemmy.kde.social
  • slotface
  • kavyap
  • thenastyranch
  • everett
  • tacticalgear
  • rosin
  • Durango
  • DreamBathrooms
  • mdbf
  • magazineikmin
  • InstantRegret
  • Youngstown
  • khanakhh
  • ethstaker
  • JUstTest
  • ngwrru68w68
  • cisconetworking
  • modclub
  • normalnudes
  • osvaldo12
  • cubers
  • GTA5RPClips
  • Leos
  • tester
  • megavids
  • provamag3
  • anitta
  • lostlight
  • All magazines