Making purposed folders to automatically render various changes to files

Starting point (doing it manually):.

After installing ImageMagick software sudo apt-get install imagemagick -y on a Debian-based distro, you can just use Terminal and your file manager.

Put  some image files in a folder. Open Terminal in that folder. Use 'magick convert' (which belongs to the ImageMagick software you installed) to resize, rename, and reformat the image files.

Example:

I placed 5 pngs into ~/Desktop/ImageFrom, altogether they weight 2mb. (I also have a folder desktop/ImageTo.) I open Terminal in ~/Desktop/ImageFrom and do mogrify:

mogrify -path ~/Desktop/ImageTo -format jpg -resize 500x500 *

This puts versions of all my pngs into my other folder, but they are now jpegs with the longest edge being 500px. They now weigh 225kb altogether.

Here ends the 'Starting point' part.

Improved way (doing it automatically):

How can we code these folder(s) so that any time we paste or drag and drop images into ~/Desktop/ImageFrom they automatically undergo this process and appear as 500px jpgs in /ImageTo ?

This 'Purposed Folders' technique could be used for lots of routine file conversion tasks, like Renaming, Stiching (multiple videos), audio processing of mp3s from wavs, etc.

---

(Note Convert and Mogrify are different. Mogrify overwrites while Convert overwrites but after creating a second version in memory, so Convert for large batches can lead to memory overage.)