Rename the file with create date in suffix

Hi, I have been trying to read filename from folder array. For each of the file I need to rename them with their create date. I am unable to use FileInfo within the same is there any alternative to assign the variables?

Just use the Move File activity to rename it. The source and destination paths can be the same.

how do I add the create date in the suffix?

Now.ToString(“someformat”)

For example, Now.ToString(“MMddyyyy”) will give back 04272022 for today.

This has a list of all the format specifiers (ie MM, dd, yyyy etc)

I dont need today’s date as an extension. Lets say a file was placed in the folder on 25-04-2022. I need the file to be renamed with the suffix of FileName_25-04-2022.csv

Hi,

Hope the following helps you.

System.IO.Path.GetFileNameWithoutExtension(item)+"_"+System.IO.File.GetCreationTime(item).ToString("dd-MM-yyyy")+System.IO.Path.GetExtension(item)

Regards,

1 Like

The date when it was placed in the folder is a little vague. Files have different dates associate with them. There is creation, update, and access times available. You’ll have to decide exactly which one you want, then use Yoichi’s method to get that value and append it to your filename.

1 Like

こんにちは、ファイル名のサフィックスにフォルダ名を付けてみました。
お役に立てれば嬉しいです。
image

[Destination Path] :

IO.Path.Combine( folder, _
IO.Path.GetFileNameWithoutExtension(file) & _
"_" & _
IO.Path.GetFileName(folder) & _
IO.Path.GetExtension(file))

1 Like

Thank you, this helped me!

1 Like

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