I need help moving files from a folder. I tried using .GetFileName but couldn’t get the right logic and syntax.
What I need is: move PDF files, but I need to move files that are the same name as XML files that are in another folder. I thought about reading the folder with the XML files and moving the PDFs when the name is the same, but I don’t know how to do that.
You can use the below:
for each item in directory.getfiles("FOLDERPATH") currentFile= new FileInfo(item) currentFileName = currentFile.Name IF currentFileName = XMLFileName...
hope these steps would help you resolve thiss
–use a assign activity and mention like this
arr_files = Directory.GetFiles(“yourfolderpath”,"*.pdf")
where arr_files is array of string variable
–now use another assign activity like this
arr_xmlfiles = Directory.GetFiles(“yourfolderpath”,"*.xml")
same array of string type variable
–now use a FOR EACH loop activity and mention the iinpuut as arr_files and change the type argument as string
–inside the loop use another for each loop and mention like this item as xml and input as arr_xmlfiles and type argument as string
–inside the inner for each loop use a IF Conditiion likethis
if this is true it will go to THEN part where use a ADD TO COLLECTION activity and mention the collection property as list_files a variable of type system.collections.generic.list(of string) with default value as new list(of string) defined in the variablle panel
–then in the item property mention as item.ToString
–followed by this IF condition use a BREAK activity to avoid looping again and again
–after the outer for each loop use a final for each loop and mention the input as list_files and iinside the loop use MOVE FILE activity where in the path property mention as item and in the destination property mention the folder path where we wantt to move
thats all you are done
hope this would help you
Check this xaml, it may help you.
SearchMyDocuments.xaml (10.5 KB)
Please mark the post as solved so that remaining users will refer to the solution
Thank you so much for contribution. I will do the tests and I inform the result.
very good. It worked perfectly, thank you very much. Thank you all for the tips.
I had to add .Replace (".pdf", “”) and .Replace (".xml", “”)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.