How to Check File Format from Folder

I have download the different attachment in folder name input folder from top30 mail now i have to check if file format is pdf then check page count in limit < 1000 and >35 else log exception and if page count is not correct then move to non apprisal folder.

Hi,
Please use Path.GetExtension(<your_file_name>) to get the Extension of the particular file

@Sandhya_Gajare
please follow these steps
1- Make File_Path Array of a string variable:
2-
cfile3
use assign activity as screenshot.
3. use for loop.


4 put if in it.
5 put condition > System.IO.Path.GetExtension(item.ToString) =“pdf”

6 put your further desirable code in If-then block

Try its working code, I am available in any query

for get pdf files use directory.getfiles(“folderpath”,“*.pdf”)-- output is array of string

and use for each for iterate the array var

use “get pdf page count” activity to get page count from pdf

next if condition if count<1000 and count>35 & in then move your file
pdf_page_count.xaml (7.5 KB)

Hi @Sandhya_Gajare

Have a look on the XAML file

GetExtension.xaml (6.9 KB)

Regards
Gokul

Hi @Sandhya_Gajare ,

You can use For each file in Folder activities to loop through the files in the folder. Best thing about the activity is that you can filter the file base on the extension like so:
image
If you do not need then you can leave blank in the “Filter by” field and additionally use Path.GetExtension and compare.

For the other about checking page number, Install the Uipath.PDF.Activities Package and Use the Get PDF Page Count to check the number of Pages in the PDF

can Provide how i can write if condition to check file format

I have to check in If Condition can you help with if condition

ok little bit wait I am sending you

Hi @Sandhya_Gajare

Update XAML

GetExtension.xaml (8.0 KB)

image

Try with this expression to if you need only PDF, Need any update the contains value

Path.GetExtension(item).Contains(".pdf")

Regards
Gokul

Main.xaml (7.8 KB)
full code please run this one by changing folder path only.

@Sandhya_Gajare Thanks.

check the format of the document if its other than pdf then log exception else consider for further processing
if the document has page count in limit < 1000 and >35 the consider the document for processing else log exception and move to “Invalid file count” folder
check if files contain Appraisal,C&W File ID:, Valuation & Advisory these keywords (anyone of them)if they have below keywords then move to “Appraisal” folder otherwise move to “Non Appraisal” folder.
Send the email back to me with below format

Please find the appraisal files in below folder:

[folder path]

How i do this can you please help me its really important for me

Discuss this topic on this thread : https://forum.uipath.com/t/extract-top30-email/467105

Regards
Gokul

Can you Help with this
check the format of the document if its other than pdf then log exception else consider for further processing
if the document has page count in limit < 1000 and >35 the consider the document for processing else log exception and move to “Invalid file count” folder
check if files contain Appraisal,C&W File ID:, Valuation & Advisory these keywords (anyone of them)if they have below keywords then move to “Appraisal” folder otherwise move to “Non Appraisal” folder.
Send the email back to me with below format

Please find the appraisal files in below folder:

[folder path]
[/quote]

1 Like

@Sandhya_Gajare I can try, but time is required for this

Take your time but can you help me with this

@Sandhya_Gajare yes, I would try my best.

Send the email back to me with below format

Please find the appraisal files in below folder:

[folder path]

I have to send outlook mail from one mail id to another which include folder path
How I can resolve this can you help me

1 Like