Delete file name.bak.jpg when file name.jpg with same size exists

Discussion related to "Everything" 1.5.
Post Reply
eswul62
Posts: 167
Joined: Wed Jul 31, 2013 6:07 am

Delete file name.bak.jpg when file name.jpg with same size exists

Post by eswul62 »

To be honest... I wasn't aware of it bit some image editor tool created bak files when updating images.
A search on ext:bak.jpg shows I have over 3000 .bak.jpg files on backup drives etc.

So I have
File name.bak.jpg 1.216.512 bytes
File name.jpg 1.216.512 bytes

I do not want to just CTRL-A Delete all the .bak files as maybe there is non-bak file of the same size.

How to delete only those .bak.jpg files when there is a 'non-bak' file with the same size.

Give up on trying with regex: I do not have the required expertise, so to say.

Anyone ??

Thanks!
dedupeit
Posts: 59
Joined: Thu Jul 28, 2022 9:52 pm

Re: Delete file name.bak.jpg when file name.jpg with same size exists

Post by dedupeit »

I would use this

Code: Select all

add-column:a a:=regexreplace(name:,".bak.jpg",".jpg") add-column:b b:=regexextract(name:,".bak.jpg")  dupe:columna,size
Column A will show the name but remove ".bak" for any files that have that. So you can look for dupes based on Column A and size.

Column B will only show ".bak.jpg" for the files that have ".bak.jpg". For "filename.jpg", it will be blank. So now you can sort by Column B, select all of the ones that have a ".bak.jpg" value for Column B and delete them.
eswul62
Posts: 167
Joined: Wed Jul 31, 2013 6:07 am

Re: Delete file name.bak.jpg when file name.jpg with same size exists

Post by eswul62 »

Thanks for taking the time to search for a solution. For good order's sake: one need to add filter on images (else other extensions are also displayed, like .mum, .cat, etc.)

I wonder whether it is possible to add size under 'a:' and 'b:' so I can see that sizes are identical.

Only those .bak.jpg files that have the same size as .jpg (non bak) with the same file name, those can be deleted.

There may also be .bak.jpg files with a different size. Those I need to check separately.

Note sure if it is possible though...

thanks again.
tuska
Posts: 1382
Joined: Thu Jul 13, 2017 9:14 am

Re: Delete file name.bak.jpg when file name.jpg with same size exists

Post by tuska »

eswul62 wrote: Fri Mar 14, 2025 11:14 am I wonder whether it is possible to add size under 'a:' and 'b:' so I can see that sizes are identical.
Maybe like this?
 
2025-03-13_File name.bak.png
2025-03-13_File name.bak.png (51.53 KiB) Viewed 2182 times
dedupeit
Posts: 59
Joined: Thu Jul 28, 2022 9:52 pm

Re: Delete file name.bak.jpg when file name.jpg with same size exists

Post by dedupeit »

eswul62 wrote: Fri Mar 14, 2025 11:14 am Thanks for taking the time to search for a solution. For good order's sake: one need to add filter on images (else other extensions are also displayed, like .mum, .cat, etc.)
You can add other filters in front of this. For example, add

Code: Select all

ext:jpg
at the front. Technically you can add it anywhere but it's most efficient at the beginning of the query.
I wonder whether it is possible to add size under 'a:' and 'b:' so I can see that sizes are identical.
Right click the header bar and add any other columns you want to see
Only those .bak.jpg files that have the same size as .jpg (non bak) with the same file name, those can be deleted.

Code: Select all

dupe:columna,size
only shows sets of files where the name (minus ".bak") matches and the size matches. Technically this could match something that you don't want to match though I don't know how much of an issue that will be for you. For example, if you had c:\folderA\file1.bak.jpg and c:\folderB\file1.back.jpg both with the same size, then both of those files would show up in the results even though there's no matching regular .jpg file.
Post Reply