Hi, I’m new here. Need some guidance into using Move File, or any that you can suggest.
I need to move a file from one location to another. At the same time, I need to rename the file according to workweek and time.
Example:
Original: AAA.xlsx
Rename to: AAA**_WW49.5_8am**.xlsx
WW49.5 - this will be based on what workweek and day we run the robot.
8am / 2pm - this will be based on if the robot runs before 2pm, then the label will be ‘8am’. If the robot runs after 2pm, then the label will be ‘2pm’.
For the week number use this function - CInt(DateTime.Now.DayOfWeek)
For the Hour logic use this code - If(Now.Date.Hour <= 14, “8.AM”, “2.PM”)
Import the below two Namespace in your workflow int he Imports section.
Imports System.Globalization
Imports System.IO
Create a variable as cal with datetype of CultureInfo.InvariantCulture.Calendar
After that, the below code will give you the expected result.
Path.GetFileNameWithoutExtension(“C:\Users\yourUserName\Desktop\AAA.xlsx”) + “" + Convert.ToString(CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(Now.Date, CalendarWeekRule.FirstDay, DayOfWeek.Monday)) + “.” + Convert.ToString(CInt(DateTime.Now.DayOfWeek)) + "” + Convert.ToString(If(Now.Date.Hour <= 14, “8.AM”, “2.PM”)) + “.xlsx”
Hi Bonus, here are the hints that will help you to achieve it…
To get the work week (assumed as week of the year): CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(Date.Now, CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule, CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek)
Note: We need to import System.Globalization for this.
To get the day (assumed as day of the week): Please use “DayOfWeek” of DateTime class & convert it into int datatype.
We can get the hour of the current time & add a condition to check if it’s before or after 2pm.
Finally we can merge the above as a new filename that you would like to move it to a new location using “Move File” activity.