Move most recent file in a folder

Looking for a way to move the most recent file in a folder using StudioX. I have tried the following using the string builder however it doesn’t seem to work.

String.Join("",Directory.GetFiles(“FolderPath”,“FileType/FIleNameSequence”,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1) )

Hi @shanalie.evans ,

How to get latest file in folder using uipath

Get the latest file in a folder

After getting the latest files using the methods mentioned in the above posts you can use the Move File activity for moving the most recent file.

Hope this helps :slight_smile:

Thank you so much for the quick response!

To clarify, I was using the Move File activity and entering the string builder into the “From” field. Is there another action or card I should be using in between?

Hi @shanalie.evans,

You can also use Get Last Modified activity by installing uipathteam.file.activities package.

Please find the attached workflow for moving the last modified file from the folder.

MoveLatestFile.zip (2.5 KB)

Thanks,
Yogesh

Darn! When I search under “All Packages” I cant seem to find that one. I tried copying and searching for key words. I will ask my organization why that might be. However in the meantime is there a reason why you can think the string builder under move file wouldn’t work?

very simple in studiox:

image

you don’t need to install any packages in studiox. just create a new project and you will have by default all needed packages for all actions you need in studiox