• Development

    Recursively Finding and Operating on the Largest n Number of Files of a Particular Type

    If you want to reverse-engineer this, you can work from left to right, adding one command at a time to see what each step does to the output.

    2016-02-03_15-52-47

    This example just lists the files we found, which is pointless given that’s what we already had before introducing the cut command.

    How about a practical example?

    Here’s how you can resize the 25 largest jpg files using mogrify (part of ImageMagick) to reduce the quality to 80:

    What if you wanted to only grab files that are larger than a specific size? One way to do it is with the find command. For example, find all files greater than 8M: