Giving unique names to screenshots in repeating task

Discuss RoboTask here
Post Reply
z-p
Posts: 2
Joined: Fri Aug 02, 2019 8:51 am

Giving unique names to screenshots in repeating task

Post by z-p »

Hi all,
Running 7.5.0.981 Demo on Windows 10 home.

My task takes four PNG (.png) screenshots at various steps of the sequence. These are named 1-4 and are saved in a particular folder.
Once the task triggers again, it takes the 4 screenshots again and saves them in the same folder but these replace the previous round of screenshots.

I need new screenshots to be named 1(2)-4(2) and the old ones (1-4) to remain intact in the folder - not to be replaced by the new ones because of the naming scheme.
Then when the task triggers again, the third round of screenshots should be named 1(3)-4(3), and so on each time the task triggers.

An alternative such as including the current date and time in the screenshot file names will also work.

Surely I'm missing something obvious here. Any suggestion welcome.

Thanks!
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: Giving unique names to screenshots in repeating task

Post by Oleg »

1-st way
You can use system variable UniqueFileName
Use the expression like this: {UniqueFileName({TempDir}\FilePrefix*.tmp)}
The variable replaced symbol '*' with 8 random chars and guarantees that it is unique file name in the folder.

2-nd way
you can form the file name with date-time values
for example this expression: {TempDir}\FilePrefix{DateTimeToFormat({DateTime},yyyy-mm-dd-hh-nn-ss)}-{mSeconds}.tmp
this name contains some fixed prefix. year, month, day, hours, minutes, seconds and milliseconds
Oleg Yershov
z-p
Posts: 2
Joined: Fri Aug 02, 2019 8:51 am

Re: Giving unique names to screenshots in repeating task

Post by z-p »

Thanks so much, it worked perfectly!

The random characters don't show that the four screenshots are a group, but the date/time certainly does.

For anyone interested, that's what I put in the File Name field for screenshot ''1'':
C:\Users\ASUS Laptop\Desktop\test screenshot\1-{DateTimeToFormat({DateTime},yyyy-mm-dd-hh-nn-ss)}.png
Then the second screenshot in the same task:
C:\Users\ASUS Laptop\Desktop\test screenshot\2-{DateTimeToFormat({DateTime},yyyy-mm-dd-hh-nn-ss)}.png

Thanks again Oleg!
:D
Post Reply