How to get the amount of selected files in automator

automator

I created a workflow to move items from one folder to another and I want to get a notification when it's done. I could create the workflow without problems but now I would like to show the number of moved files on the notification pop-up.

How can I get the number of files?

Basically I'm copying downloaded files to a "Downloads" folder on iCloud Drive. After the files are copied, I would like to show a notification saying "{NumberOfFiles} moved successfully."

enter image description here

Best Answer

You can use the following Apple Script to set a variable (named item_count) to the number of items returned from the previous action:

on run {input, parameters}
    set (value of variable "item_count" of front workflow) to (count of input)
    return input
end run

The list of items is simply passed through.

You could use it like this:

enter image description here