I am trying to use a replace function to rename a file with yesterday’s date. I get an error stating “Compiler error(s) encountered processing expression. Identifier expected”. Here is my expression
file.Replace(“U:\clients\097700 ZZ KDW\0054 Practice M\DocketNavigatorReports\NEW CASE EREPORT - UIPath Report.xlsx”,“DocketNavigatorReport”+ datetime.now.AddDays(-1).ToString.(“MM-dd-yyyy”)+“.xlsx”)
Where did I go wrong? Thank you in advance for any help!
Hi, I assume “file” is your string variable and then you put a .Replace on it.
You are replacing the full path “U:[…].xlsx” with like half a path. That won’t work!
Also there is one dot ( . ) too much in your Date to String conversion - fixed that for you: Now.AddDays(-1).ToString("MM-dd-yyyy")
Instead of using replace, consider putting your filepath together in parts. For example:
FilePath = FolderPath + FileName + FileExtension
Yes. I have a file downloaded to a directory every day but it downloads with the same name each time. i want to rename it with a date in the name. When i tried to use the move file activity i got an error when adding in the date string. I’m sorry I am still very new to UiPath.
You almost got it right. You don’t need to put the full filepath string into the replace function, just the part that you actually want to replace, which is usually the filename. If you really only want to add the date, you can do it like this: