How to get file creation date and time using AA 360
Hi
Use the package File and Folder Attributes Package.
https://botstore.automationanywhere.com/bot/file-and-folder-attributes-package
Let us know your feedback
Regards
The link does not work anymore, nor can I find the file and folder attribute package in the bot store.
Why is it gone? What are people doing now to identify the attributes of files and folders?
I’m trying to get the creation date of a file.
Just out of curiosity, are you looking specifically for the (creation/modified/etc.) date? Or are you trying to do something like capture the most recent file? There are different paths you can follow depending on the desired outcome, but they’re both kind of ugly:
Finding the Date Itself:
- I would suggest downloading the Bot Store templates into your Control Room:
- One of these templates is called Get File and Folder Information. It uses an included FileFolderInfo.dll file (again, why not just make it native?) to obtain things like file size, created/modified date, etc.
- The good thing is you can copy the template and modify to your needs, rather than starting from scratch.
Finding a recently created or modified File:
- If you’re trying to do something like find the most recently created file, you can do something like this without installing anything extra:
- Loop through files in a folder:
-
Set an If condition, checking for the file Created or Modified date. Beating the dead horse, the action is obviously obtaining the file info in the background; it just doesn’t expose it for our use.
-
Unfortunately, you have to give it a time frame. The one benefit is, if you are creating/modifying the file in your bot, you can use the “Relative to runtime” to narrow the timeframe down:
-
Then perform whichever actions you would like on the file.
As I said, neither option is perfect, but hope that helps anyone who wanders by on this topic.
JLogan3o13 thank you so much for all these details. I was trying to clean up error screen shots whenever my error recording bot gets triggered.
So the if file date condition was super helpful; didn't know that was an option. I set a global value for retention days, capture todays day and then subtract the retention value and verify that the created date is before the date.
It is just not optimal, as you said. Why is the date that I have to compare against in the If statement a string? It doesn't make sense and complicates the whole thing. Maybe that's because I’m new or maybe that's just the way it is…
I see a lot of AA packages and videos and which more of these features would be integrated natively. Would simplify some of the learning curve for sure.
Thanks again!
Python has a number of ways to do this, but it requires that Python is installed on your bot dev system and your bot runners (in an Enterprise environment).
For clarity, here is the Python code:
import os, time
def getFileCreationDate(filePath):
ctime = os.path.getctime(filePath)
return time.ctime(ctime)
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.