I am want to rename my recently downloaded file from download folder which is part of my automation can anyone help how to identify recently downloaded file and rename it
Get Newest file in folder
To get the path of the last updated file use this code (put it in an Assign activity for example) :
PATH = Directory.GetFiles(download_folder).[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(your_extension)).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString()
dowload_folder is the path to your download folder. The place where the file has been uploaded.
your_extension is the type of file you are looking for. For example if you want to get an Excel file then write → “.xlsx”
And in case you need the original name of the uploaded file then write :
NAME = Path.GetFileName(PATH)
For Renaming your file you “move” the file to the same folder (with Move File activity), just with a different name.
Tell me if it’s ok for you
@Camille361 here in the Function(X) so X stands for?
You don’t need to define x. Just write it like that in the activity.