Rename and Move File

Hello,

I want the last step in my workflow to rename and move files to another folder (that includes yesterdays date), how do I do that

1 Like

use move file activity with new filename @sparkplug93

1 Like

How do i rename it though? i used item + datetimenowtostring and got an error

1 Like

@sparkplug93,

can you share few file names including the dateformat?

I’m just running through item variable from a folder then using item + DateTime.Now.ToString(“dd-MM-yyyy”) and getting an error

Try like this,

Path.GetFileNameWithoutExtension("yours source file name").ToString+"_"+System.DateTime.Now.Date.ToString("MMddyyyy") + ".xlsx"
2 Likes

would I use item instead of the first part? Or can I use assign and get file name?

@sparkplug93,

If your item containing full path of a file “C:\Users\Admin\Desktop\Trans.xlsx” then pass it like

Path.GetFileNameWithoutExtension(item).ToString+"_"+System.DateTime.Now.Date.ToString("MMddyyyy") + ".xlsx"

Move File: Could not find file ‘C:\Users\MichaelC\Documents\UiPath\QuickLibrary\Item11122019.xlsx’.
Was the error I got

Filename+System.DateTime.Now.Date.ToString(“MMddyyyy”) + “.xlsx” where I assigned filename using getfilename(“item”) but my folder isn’t the one above

1 Like

this would be the expression that includes the yesterday date
Path.GetFileNameWithoutExtension(item.ToString)+“_”+System.DateTime.Now.AddDays(-1).ToString(“dd_MM_yyyy”) + “.xlsx”

Cheers @sparkplug93

Fine
you need to mention the path property with value as item.tostring and destination property as
Path.GetFileNameWithoutExtension(item.ToString)+“_”+System.DateTime.Now.AddDays(-1).ToString(“dd_MM_yyyy”) + “.xlsx”

Cheers @sparkplug93

I’m getting the same error. It is looking for item in the wrong folder.

Fine
may i know what is the value of item.tostring, kindly check once whether the folder path has that file in it

Cheers @sparkplug93

my folder is report\filename and it’s looking in the uipath\filename

that is fine buddy
does the item.ToString also refers that
@sparkplug93

yep. I used another assign getfiles and that is also looking in the incorrect folder

@sparkplug93
print this “item.ToString” in a Write Line and check whether it has the expected file path or not

1 Like

Yes it is

yes it is

Data Pull.xaml (15.0 KB)

1 Like