Merge 2 folders, keep smallest version of each file

Hi,

I'm sure Opus has the capability to help me, but I'm not sure how to achieve it.

I have a massive directory of images for a website that needed optimizing. (re-sampling). 60,000+ files. I'm left with two versions of the directory which needs to be merged, retaining the smaller version of the file no matter which directory it is from. (Both directories ore identical except file sizes and modified dates.)

Can i achieve this with Opus and can anyone point me in the right direction.

Thanks.

If the filenames are unique (to each pair of files), the duplicate finder could be used.

Otherwise, I think it would take a bit of scripting to build a list of which files to copy.

(We have a built-in "keep newer" option for copying/moving, but not currently a "keep larger/smaller".)

But you could also tackle the problem at the other end: For example, I have a custom "PNG Crush" script in my Opus config which runs various PNG compression tools on files and then selects the smallest result and keeps that. (If the original file was smaller than the output of all the tools/modes, then the original is kept.) Using that, there's no second stage needed to select the best files as it was already done. (Of course, this doesn't help if you've already done the compressing, but it may be worth keeping in mind if the same workflow is to be repeated on more files.)

Thanks Leo,

I guess i hoped there was a hidden 'keep large/small' option. Maybe a future feature :slight_smile:

I'll look at my options, cheers.

Shout if you need help with a script.

We may be able to write one for you, but may need a bit more detail.

e.g. Does it need to be recursive or just the visible files directly below two folders?

(From the first post, I'm assuming all file names and paths match on both sides, relative to the parent.)

That's the only missing detail I can think of, but if there are any other particulars about how the script should work that you can think of, they might help steer it in the best direction. Always easier to know everything up front than try to retrofit new requirements.

Thanks for the offer, but don't worry, I resolved it another way.

I've been wanting to get my head around the scripting tools for some time now... must find the time some day! :confused: