Q: Regex to find modified images.

Discussion related to "Everything" 1.5 Alpha.
Post Reply
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Q: Regex to find modified images.

Post by Bamsen »

Hi,

I have several files of this format where the modified image has "-1" added
"C:\Dropbox\Camera Uploads\2023-07-18 18.45.43.jpg"
"C:\Dropbox\Camera Uploads\2023-07-18 18.45.43-1.jpg"

I am trying to create a search that will find all these pairs
My attempt look like this: regex:"(^.*)-1\.jpg|\1"
The regex finds all files that end with -1.jpg and captures the start of the filename in group 1
Then the |\1 should match all files with just the content of capture group 1.
This does not work.

regex:"(^.*)-1\.jpg" correctly finds all the modified files and the regular-expression-match-1 column contains the correct value. (2023-07-18 18.45.43)
manually recreating the capture group like regex:"(^.*)-1\.jpg|2023-07-18 18.45.43" does work.

What is the correct way to do this?

---
Regards Morten
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Q: Regex to find modified images.

Post by Bamsen »

I have now realized that of cause I can not use capture groups to find stuff in other file names. It is naturally one line at a time. :D

But my question still stands: How can I find these files?
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Q: Regex to find modified images.

Post by therube »

regex:"(^.*)-1\.jpg
2023-07-18 18.45.43

I'm thinking...

You need to "group" the 2023, <2023-07-18 18.45.43>

So...
<2023-07-18 18.45.43> | regex:(^.*)-1\.jpg
.


viewtopic.php?p=58761#p58761
therube
Posts: 4985
Joined: Thu Sep 03, 2009 6:48 pm

Re: Q: Regex to find modified images.

Post by therube »

There is also a way to find name / name-1 pairs kind of thing, just like you're looking to do.
(I don't recall how, but it is mentioned in these parts.)
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Q: Regex to find modified images.

Post by NotNull »

Untested ...

For jpg files

Code: Select all

file:   < regex:"^(.*)-1\.jpg$"   fileexists:\1.jpg >  |  < regex:"^(.*)\.jpg$"   fileexists:\1-1.jpg >

For any file extension:

Code: Select all

file:   < regex:"^(.*)-1\.([^.]+)$"   fileexist:\1.\2 >  |  < regex:"^(.*)\.([^.]+)$"   fileexist:\1-1.\2 > 
file-exist:
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Q: Regex to find modified images.

Post by Bamsen »

That worked! :D
I had not seen file-exists: before.

I did try to use \d in file-exists: to match any number -1, -2, -3.... but that did not work for me.
Is there a syntax where I can do something like that? (ie: fileexists:\1-\d.jpg)
file: < regex:"^(.*)-\d\.jpg$" fileexists:\1.jpg > | < regex:"^(.*)\.jpg$" fileexists:\1-\d.jpg >
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Q: Regex to find modified images.

Post by NotNull »

There is, but it will probably be quite taxing on your system (better to test first with a small folder):

Code: Select all

file:   < regex:"^(.*)-\d\.([^.]+)$"   regex:siblingname:^$1:\.$2:$ > |  < regex:"^(.*)\.([^.]+)$"   regex:siblingname:^$1:-\d\.$2:$ >

Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Q: Regex to find modified images.

Post by Bamsen »

There is a reason this tool is called EVERYTHING! I never stop being amazed about all the stuff in here! :)

Unfortunately any attempt to use regex:siblingname: on even a small directory with 596 items crashes after a couple of seconds.

But I have two questions. :)
  1. Why does siblingname work with regex but fileexists does not?
  2. How am I supposed to find my way in all these options without help from someone that happens to know? (Thank you to NotNull!)
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Q: Regex to find modified images.

Post by void »

Thank you for the crash report, I'll have this fixed in the next alpha update.

The crash is caused by a regex optimization.

I'll post a fix here once it's ready for testing.

For now, please try:

Code: Select all

file:   < no-fast-regex:regex:"^(.*)-\d\.([^.]+)$"   no-fast-regex:regex:siblingname:^$1:\.$2:$ > |  < no-fast-regex:regex:"^(.*)\.([^.]+)$"   no-fast-regex:regex:siblingname:^$1:-\d\.$2:$ >
NotNull
Posts: 5461
Joined: Wed May 24, 2017 9:22 pm

Re: Q: Regex to find modified images.

Post by NotNull »

1. fileexists: requires an exact filename, not a (regex) pattern.

2. They are listed here for now (alpha version). That will be put on the support pages in the future.

But there are lots of helpful people here on the forums to help you out (there are indeed a lot of options ..)
void
Developer
Posts: 16773
Joined: Fri Oct 16, 2009 11:31 pm

Re: Q: Regex to find modified images.

Post by void »

Everything 1.5.0.1353a fixes a crash when capturing text with regex.
Bamsen
Posts: 24
Joined: Thu Dec 09, 2021 9:16 am

Re: Q: Regex to find modified images.

Post by Bamsen »

The search that crashed before, now ran quickly on my entire disk. :D
Post Reply