How to move latest pdf files

How to move latest downloaded pdf file to another folder (select only specific pdf files)

Hi @Suraj_Gaikwad_Nuvama_Grou ,

Check this steps

Use the “Assign” activity to assign the directory path where your downloaded PDF files are stored to a variable. For example, you can create a variable named “DownloadFolderPath” and assign it the value of the directory path where your downloaded PDF files are stored.

Use the “Assign” activity to assign the directory path where you want to move the PDF file to another variable. For example, you can create a variable named “NewFolderPath” and assign it the value of the directory path where you want to move the PDF file.

Use the “Directory.GetFiles” activity to get a list of all the PDF files in the “DownloadFolderPath” directory. Store the output in a variable. For example, you can create a variable named “PDFFiles” and use the following expression: Directory.GetFiles(DownloadFolderPath, “*.pdf”).

Use a “For Each” loop to loop through each PDF file in the “PDFFiles” variable.

Inside the loop, use an “If” statement to check if the current PDF file name matches the name of the file that you want to move. If it does, use the “Move File” activity to move the PDF file to the “NewFolderPath” directory. For example, you can use the following expression: Move File(item, Path.Combine(NewFolderPath, Path.GetFileName(item))).

End the “For Each” loop.

Thanks,

Hey @Suraj_Gaikwad_Nuvama_Grou ,
Please try this Query

Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads").[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(".pdf")).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString

image

Regards,

1 Like

okay i will try this

i try but its working

@Suraj_Gaikwad_Nuvama_Grou ,
Can I know what is the error you are getting?

i m trying to change assign variable string to array string but there is an error
(cannot assign from type system.string to type system.string array )
in assign activity

@Suraj_Gaikwad_Nuvama_Grou ,
Try this and make sure your double quotes are proper

Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Downloads").[Select](Function(x) New FileInfo(x)).Where(Function(f) f.Extension.Equals(".pdf")).OrderByDescending(Function(x) x.LastWriteTime).Take(1).ToArray()(0).ToString

Regards,

1 Like

this string i hve to use in single assign only

only one file moving

@Suraj_Gaikwad_Nuvama_Grou ,
Yes according to your requirement the latest downloaded file from the download folder should move to other folder right?

yes ! but there is multiple files are downloading there

@Suraj_Gaikwad_Nuvama_Grou ,
Can you Just change the setting in Chrome .Like instead of downloading directly in the downloads folder You can make settings in Chrome so that when you click download it will ask where to download and there you can Type into your Actual required folder

For that,
Go to Chrome->Settings->Downloads → Now enable this option

Regards,

1 Like

okay
thank you

@Suraj_Gaikwad_Nuvama_Grou ,
Did you try with that?
Is it working fine now?

4 Likes

Yes but moving only one file


Now I’m trying this also but here also moving single file only but i have to change the string which shown in pic there the last name can we for multiple files
There I’m using first so only first file is moving

This is the files which I have to move

I tried but getting confused

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