Copy the last file name every 24h and paste it in another area


I want to copy the name of the latest file and then copy it when I open excel and save the excel file name by the name that I already copied it
Please any idea to solve it :pray: :pray: :roll_eyes:

Hi @Imene_ZARAI,

Kindly try this assign.

strFileName = Path.GetFileName(Directory.GetFiles(yourFolderPath).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0))

Regards.
Ömer

thanks for the reply I will try it

Hi @Imene_ZARAI here the linq to get the last file name:

file=(
From f In New DirectoryInfo(filePath).GetFiles(“*.txt”).Cast(Of FileInfo)
Order By f.LastWriteTime Descending
Select f
).Last()

variable type should be

thank you for the reply :pray:

Hi @Imene_ZARAI,

Did it work for you?

Regards.
Ömer

Hello @Imene_ZARAI

please find the below doc.

Another approach is to sue the Find Each File In Folder activity. Give Order By as “Created date newest first”.

Then use break to break from loop after getting the first file name.

Thanks

yes it worked thank you

thanks for replying

You are welcome @Imene_ZARAI. :slight_smile:

Have a nice day.

Regards
Ömer

1 Like

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