Search code examples
copycomparebatch-processingfilesize

copy (multiple) files only if filesize is smaller


I'm trying to make my image reference library take up less space. I know how to make Photoshop batch save directories of images with a particular amount of compression. BUT some of my images were originally save with more compression than what I would have done.

So I wind up with two directories of images, some of the newer files have a larger filesize, some smaller, and some the same. I want to copy over the new images into the old directory, excluding any files that have a larger filesize (or the same, though these probably aren't numerous enough for me to care about the extra time to process them).

I obviously don't want to sit there and parse through each file, but other than that I'm not picky about how it gets tackled.

running Windows 10, btw.


Solution

  • We have similar situations. Instead of Photoshop, I use FFmpeg (using its qscale option) to batch re-encode multiple images into a subfolder then use XXCOPY to overwrite only the larger original source images. In fact I ended up creating my BATCH file which let FFmpeg do the batch e-encoding (using its "best" qscale setting), then let ExifTool batch copy the metadata to the newly encoded images, then let XXCOPY copy only the smaller newly created images. All automated, with the "new" folder and its leftover newly created but larger-sized images deleted too. Thus I save considerable disk space, as I have many images categorized/grouped in many different folders. But you should make a test run first or back up your images. I hope this works for you.

    Here is my XXCOPY command line:
    xxcopy "C:\SOURCE" "C:\DESTINATION" /s /bzs /y

    The original post/forum where I learned this from is:

    overwrite only files wich are smaller
    https://groups.google.com/forum/#!topic/alt.msdos.batch.nt/Agooyf23kFw

    Just to add, XXCOPY can also do it if the larger file size is wanted instead which I think is /BZL. I think it's also mentioned in that original post/forum.