Move files with certain text in file name

Hi.

I have String = directory.getfiles("*.pdf",searchoption.alldirectories)

How do I then move all files which start with OCR* to another folder (a new folder called “OCR” in the files current directory. Before i continue processing the rest of the pdf files that don’t contain “OCR”?

Thank you

1 Like

Hi @MarkC1500,

If only the pdf files which start with OCR* should be moved to another folder a simple solution could be changing the pattern used in the getFiles function:

Directory.GetFiles(selectFolder,“OCR.pdf*”,SearchOption.AllDirectories)

Best Regards,
Susana

2 Likes

Hi @Susana

If I did your suggestion all the files originally extracted from directory and all sub folders will be moved to the same folder.

I’m trying to process all files in directory and sub folders and then move them to a new folder called “OCR” in their corresponding sub folder.

Thanks

Mark

Hi @MarkC1500,

You can get the directory name of each file and then create, if it does not already exists, the subfolder OCR. The last step is moving the file to the assigned folder.

Let me know if you need further information.

Best Regards,
Susana

Hi,

Im trying to read file(pdf) content(Heading) and based on that name i want to move those files only.

is it possible ? currently my workflow, get all pdf files in the folder and opens then one by one then screen scraps the heading and stores it in a string.

now im trying to find a way to move them according to a condition. If the output variable from screen scrap reads “Invoice”, i want that pdf to be moved to a new folder.

Would appreciate feedback :):slightly_smiling_face:

I would also like to know how this can be.

The idea is simple. All files inside the folder, should move and renamed based on their content.

Thank you