Hi, I need help with the following according to its sequence.
- How to save the latest file from the downloads folder
- How do I move this file to another folder
- How do I rename this file
I can work with variables.
Regards,
Shannon
Hi, I need help with the following according to its sequence.
I can work with variables.
Regards,
Shannon
Hey @Shannon_Quek ,
1.You can use this
Directory.GetFiles(“C:\Users\Jithesh.R\Downloads\Whatsapp”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)
2.You can use Move File Activity to move the file from one location to another
Regards,
this expression would get you the latest file
str_filepath = Directory.GetFiles(yourfolder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
Use this
In the To you can give the path that you want to be renamed as it will work.
Hope this helps
Cheers.
@Shannon_Quek
You can try this then.
(Assuming you file is an .xlsx File)
Directory.GetFiles(folder_path,“.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)
Cheers,
Do I need to change any value under Assign function?
Mine is to save the latest file from Downloads, there is no additional folder that I have to access to
which function do i use this under? and for the folder_path is it a variable or the folder path link?
@Shannon_Quek
Folder_Path is the path of the folder where your Files Exists
Try Using You path instead of this(“C:\Users\Jithesh.R\Downloads\Whatsapp”),
Directory.GetFiles(“C:\Users\Jithesh.R\Downloads\Whatsapp”,“*.xlsx”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1)
Note : Make Sure to check the Double Quotes(“”) while copy pasting.
Output
Regards,
@Shannon_Quek ,
If you want to take the files directly from downloads you can try this
This will provide your required output
LatestFile(StringType) =Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+“\Downloads”).[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(“.xlsx”)).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString
Output :
Cheers,
is there variable in the expression? if so, what is the variable type?
@Shannon_Quek ,
Nothing You just Take Assign activity and continue with the same query
Left side of the assign activity u can create String Type Variable
Right side you can provide below query
Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+“\Downloads”).[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(“.xlsx”)).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString
Reagrds,
for the rename file function, what do i put under file?
Use Rename File Activity
Provide the same variable in the “File” Section that is LatestFileVariable
Provide a New Name whichever you want inside Double Quotes Like below
Cheers,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.