Announcement

Collapse
No announcement yet.

Exclude files where left file is smaller than right file?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exclude files where left file is smaller than right file?

    I am using Beyond Compare to work with my homepage files (SFTP upload/download/delete/filter...). I did recompress all PNG image files using "ImageMagick" - many files were originally uploaded exporting from Photoshop, which did not such a job in compression.
    Now I want to upload the result, but only those files that have been compresses with a better ratio. Each compression filter and strategy has its pro's and con's, so many images have been reduced in size, but some have been increased.

    So I hope there is a way to exclude all files that are bigger on the right side.

    If that is not possible out of the box, I will have to write a little custom comparer.

    Just for reference, if you want also to re-compress all PNG files recursive from the command prompt inside the root folder:
    FOR /R %f IN (*.png) DO magick mogrify "%f" -depth 24 -define png:compression-filter=2 -define png:compression-level=9 -define png:compression-strategy=2

  • #2
    Hello,

    Thanks for the interesting example case. Unfortunately, BC4 does not have this type of greater than or less than filtering for left vs. right. Size filters can be set as an absolute value, to exclude files greater or less than a static size, and Timestamps can be compared as Newer or Older, but sizes can not be filtered for Larger or Smaller.
    Aaron P Scooter Software

    Comment


    • #3
      Thank you for the quick answer - that helps to concentrate on the correct strategy to solve the problem.

      I've written a little C# program:

      Code:
      var cmdLine = string.Join(" ", Environment.GetCommandLineArgs().Skip(1));
      var paths = cmdLine.Split("|");
      var length1 = new FileInfo(paths[0]).Length;
      var length2 = new FileInfo(paths[1]).Length;
      Environment.ExitCode = length1 > length2 ? 0 : 1;
      That can be used as a new "File Format":
      Code:
      ....\CompareSize.exe %1|%2
      and returns 0 or 1 depending on whether the left file is bigger or not.

      Unfortunately, the file format comparer does seem to not get a path to a downloaded copy of the file (like the converters for text-file-formats). If one of the two files is on an FTP-profile, the parameter %1 will be something like "profile:[email protected]?path/file.ext, so I first needed to download all files and the compare the local folders.
      But as always: there are so many things you can do with Beyond Compare - I am really happy to have such a useful tool that can be extended.

      Comment


      • #4
        I'm new to BC, and I gotta say it's super cool how you can write a C# code of your own and use it like this. I've never seen an application with this much user extensibility before!

        Comment


        • #5
          We have some other examples here for Open With commands:
          https://www.scootersoftware.com/supp...kb_openwithapp

          You might find this article, using RESX files and an RESX utility, useful for how to incorporate as a File Format's conversion utility:
          http://www.scootersoftware.com/suppo...rnalconversion
          This one is for file level or rules-based scanning of aligned pairs in the Folder Compare.
          Aaron P Scooter Software

          Comment

          Working...
          X