Add timestamp and then file extension (xlsx) to a file and move to the archive Folder

Hi there,

I want to add timestamp and file extension to the file and eventually move to the Archive Folder…Can anyone advise, please?

Input Files 1

I look forward to your response

Hi @Sisay_Dinku,
Use move file activity
In destination use below format to add timestamp

"C:/arivu/Archive/RPA"+DateTime.Now.ToString("HHmmss")+".xlsx"

Regards,
Arivu

@arivu96

I want to dynamically pass and the eventually the file would look like for example → RPA 12-11-2022.xlsx

Hi @Sisay_Dinku ,
Try below code
"C:/arivu/Archive/"+Path.GetFileNameWithoutExtension(item.ToString)+DateTime.Now.ToString("MM-dd-yyyy")+".xlsx"

Regards,
Arivu

Thank you for the effort.
I got the following error

I think I have to do a couple of things

  • removing the pre-existing ‘xlsx’ as you can see in the above error message
  • adding the timestamp
  • adding the extension (xlsx)

Q: Where should I make these changes? Is it before moving at the current location and moving after the renaming has been done?

HI @Sisay_Dinku ,

can you share the syntax you wrote. or screenshot

Regards,
Arivu

Sure.
item+Path.GetFileNameWithoutExtension(item.ToString)+DateTime.Now.ToString(“MM-dd-yyyy”)+“.xlsx”

Hi @Sisay_Dinku ,
try to mention the correct path , where you need to save

item+Path.GetFileNameWithoutExtension(item.ToString)+DateTime.Now.ToString("MM-dd-yyyy")+".xlsx"

in above syntax “item” is full path of your source file path, so provide the destination folder path

Regards,
Arivu

Hi @Arivu,

I want to save it here

str_archivePath location? its inside the project folder ?
try below
str_archivePath - assign in which folder you need to save and use below syntax
str_archivePath+Path.GetFileNameWithoutExtension(item.ToString)+DateTime.Now.ToString("MM-dd-yyyy")+".xlsx"

Regards,
Arivu

No, the folder is NOT inside the project folder.
I am able to send to the archive folder the existing folder. However, the issue I have is with renaming and adding time stamps and sending them to the archive folder.

Hi Team,

Can anyone help with this?

Hi @Sisay_Dinku ,

Can you tell me where you need to store the file ? Path?

Regards,
Arivu

@arivu96

Here is the folder path, where I want to store the processed files

Hi @Sisay_Dinku ,

You are almost there. The “From” value being passed to the Move file activity is correct!

All you need to do it put the full new path in the “To” value of the move file activity:-

Path.Combine(str_ArchivePath, Path.GetFileNameWithoutExtension(item.ToString)+DateTime.Now.ToString(“MM-dd-yyyy”)+“.xlsx”)

@pradumn30

Thank you and this one worked out. I appreciate that @pradumn30

1 Like

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