MacOS – How to get certain types of files dropped in certain folders based on file type

applescriptautomatormacos

I was wondering if it is possible to have the following:

In my Downloads folder, I have 2 subfolders : IMAGES and VIDEOS. Is it possible to automatically move every image downloaded to the Downloads folder to the IMAGES folder, and if VIDEO files are downloaded in the Downloads folder, it should go into the VIDEOS subfolder?

I thought I could do it with Smart Folders but it does not seems to be working.

Best Answer

You can create two folder actions, one for images:

enter image description here

one for videos:

enter image description here

Both should be setup to receive files from Downloads folder.

The first step filters images and videos files.

The second step moves those files in the appropriate folder.

Be sure that folder action is attached to your Downloads directory (right click on directory, Services\Folder Actions Setup...).

To let Automator wait for the download to complete, you can add a Run AppleScript step, before the Move Finder Items step, similar to this:

on run {input, parameters}
    if input is {} then
        return {}
    end if

    repeat
        delay 1
        set {size:fileSize, busy status:Busy} to (info for (input as alias))
        if not Busy and (fileSize is greater than 0) then return input
    end repeat
end run

enter image description here