I have an automation that downloads bank statements, I have a “wait for download” activity that kicks off once the download is successful, the goal is to take the file from the system downloads and place it into the correct folder AND create that folder if it does not exist. For example, statement is downloaded for January 2022 but there is not a 2022 folder or the sub folder January the automation should create them both.
–>Agency Commission (folder)
—> Year (Folder)
Every month when the unattended automation runs it should create a folder for the current month/year if not existing and place the downloaded file in this folder.
I have tried the move file, create file and create folder and I am stuck. Seems to me that this should be possible
before creating folder , you can use “path exists” activity to check if year folder is present or not .if path exists is false then only create folder.
Do the same check for month folder.
hope this will be helpful
Use "Delete folder" activity to delete the existing folder.
You can use a Folder exists activity and use a if activity. If folder doesn’t exists, use a create folder activity to create new folder.
Error1 : File or Folder already Exists
- Make sure you check the folder exists or not before creating
- That can be done using an activity Path Exists. It returns a boolean value.If it returns True then don’t create any folder, else create folder
Error2: Could not find part of a path
- In the To field of the Move Activity you should also mention the file name along with the extension
Ex: Lets say you want to move the excel file then in the To field you should write like below one
Also, try printing the From and To Fields of move file activity and see what is the path giving for better debugging
I took the method of checking for path first and then ran into issues with sometimes it working and sometimes it not working the True/False was sometimes not correct. After deeper dive it seems that sometimes the current environment returns the computer name, and sometimes it returns the user name…
Have you ever seen this? I know the solution is to just change the folder path to always be "Robot" since the windows user account is Robot, but I would prefer to keep this based on system environment username so it will work on other machines if I decide to move machines in the future…
@Nathan_Betters1 Did you try with this
Environment.UserName. It returns user name who currently logged in
@Gokul_Jayakumar Can you let me know what is the value that was assigned to i_CurrentEnvironment variable
The argument has an input of “current environment username”.
Sometimes that pulls in “desktop-0396” and sometimes it pulls in “Robot” which is the windows account username.
I cant figure out why sometimes the assignment pulls correct and sometimes not