Creating dynamic Folders and files

Hi,

I am looking to capture screenshots and store them in a folder which has current time as appended file name. However, I receive an error saying “Unable to find the save directory”

Here is my code

put now into executionTime
put “Parent folder location” && executionTime into resultsFolder
create new folder resultsFolder
put resultsFolder & “/imageFileName.jpeg” into fileName
CaptureScreen (Name: fileName)

All I need is I must be able to create a dynamic folder with latest timestamp.

Anyone please advice.

Thanks,
Vasavi

If you’re running Eggplant on a Mac, I believe the problem arises from the fact that ‘now’ (and all of the built-in time formats) use colons “:” as separators between the hour, minute, and second. Unfortunately on the Mac colons are treated as path separators so they can’t really be used in a file name. To avoid this problem, you’ll need to either change the colons to some other character like this:

put now into executionTime
replace every ":" in executionTime with "_"

or, better yet I think, create your own format using the formattedTime function like this:

put formattedTime("%Y-%m-%d %H_%M_%S") into executionTime

Hopefully that will take care of the problem for you.

Thank you very much. This helps me. I am using formattedTime function as per your suggestion.

Vasavi