File name count variable reset

Hi all,

I'm running a Macro that lets me Copy > Write Text to File (.txt) > Save it to Desktop.

A perl script is counting the file name, so new documents don't overwrite each other.

perl -e 'print ++$ENV{KMVAR_Count}'

However, the count is infinite. So if I'm at, say, count 2 and I move the files from my desktop, the script keeps counting from 2 as opposed to resetting to 0.

I need a simple "IF/THEN" to complete this macro. Any help is greatly appreciated.