Rename a file when using the "Move File" activity

Hi,

I wish to move files in a loop and rename the moved file with a date added in the end. By reading another post I see that if I put the updated filename in the “To” field inside the move file activity, it should rename the file when the move is executed. I have attempted to do this but getting error messages saying “Could not find a part of the path”

However, if I move the file without trying to rename, it works fine. Please could someone help me see what am I doing wrong here? In the attachment you’ll see the error message and code I used to rename the file. In the “To” field, if I just write the variable OutputFolderPath, it works fine and mocves the file. But when I added the filename - I get the error.

Many thanks in advance !

1 Like

Nevermind - I found my mistake. I was using the date format with “/” but filenames doesn’t support this character so I replaced the format with “-” and it is working perfectly. For anyone trying to do the same, the final working code is -

OutputFolderPath + item.ToString.Replace(“.jpg”, DateTime.Today.AddDays(DayCounter).ToString(“dd-MM-yyyy”)+ “.jpg”)

here, outputfolderpath is a variable containing the destination path and daycounter is also a variable.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.