Community

TIP: Getting the FileName only

What if we want to get just the file name of the document we are processing? We all know that we can get the full path and file name of the file if we use the service field "Image Source" but that might be more that what we want. By using the following script, this will cut out all the path information and leave you with the filename only:

dim strFilename, objFilename, objFile, strFile
me.Field("FileNameOnly").Value = me.Document.Pages.Item(0).ImageSource
strFilename = me.Field("FileNameOnly").Value
objFilename = split(strFilename,"\")
For each objFile in objFilename
strFile = objFile
next
me.Field("FileNameOnly").Value = strFile

You can download the sample project here: http://www.abbyydownloads.com/filename.zip

To open the project, you must be using at least version 10.0.4.1486 of FlexiCapture 10
1

Comments

5 comments

  • Avatar
    DanAyo
    Here is a script that we've used successfully.


    ' *****Rule*********

    me.Field("Field").Text = me.Document.Pages.Item(0).ImageSource
    Dim pos
    pos = InStrRev(me.Field("Field").Text,"\")
    me.Field("Field").Text = Mid(me.Field("Field").Text , pos + 1)

    ' *****\Rule*********



    1
  • Avatar
    Feri Santosa
    I usually use windows system IO :


    dim fullpath as string = me.document.pages.item(0).imagesource
    dim filename as string = system.io.path.getfilename(fullpath)




    0
  • Avatar
    Kalyani
    Hi ,
    Its a 2 line code so thought to share :
    In Flexicapture 10 In Recognition stage (Advanced Workflow->Recognition->ExitRoute ->StageName->Rule->Script) under script u can write the following code :-

    using System ;
    string documentName = Document.Pages[0].ImageSourceFileSubPath;
    if (documentName != null)
    {
    //write "documentName" in text file and check ;
    //Access the content of that text file to get file name only ....
    }

    Hope this helps us !
    0
  • Avatar
    Lokesh Saluja

    I set-up Mailbox monitoring on Exchange and am now directly feeding the invoices to Abbyy. Done using Image Import Profiles. However that has corrupted my initially trained document definition (I used to add pdfs from a physical location and Abbyy was able to map the file path under image source).

     

    The new file path looks something like this  (A combination of sender's email, other email addresses sent to, subject of email and possibly name of the attachement) - 

    1<1>43<Exchange Mailbox: customer.deductions/Inbox>198<32<abc@abc.com>28<tabc@abc.com>25<tabc@abc.com>31<tabc@abc.com>38<tabc@abc.com>>25<2020-07-02 13:51:31 (UTC)>47<New Brunswick Corporation_CBP0004273.pdf>26<AccountsReceivable>27<AccountsReceivable@abc.com>5<false>5<false>47<New Brunswick Corporation_CBP0004273.pdf>



    How can I fetch the name of the invoice - "New Brunswick Corporation_CBP0004273.pdf" which comes in the end of the above string and add it to another string (The folder path where I add the images). The words will not always be the same, Sometimes it'll be "New Brunswick Corporation_CBP0004273.pdf", other times it'll be just "CBP0004273.pdf", other times "CB009273.pdf" and also could be like "INVMA0002072.pdf" OR "New Brunswick Corporation_INVMA0002002.pdf" ?

    Please recommend how to fetch the name of an attachment when document is added from a mailbox monitor either directly or from the above string of data from image source?

    2
  • Avatar
    Keith Hay

    Obviously, the format for the Image Source Service field is different depending on the method of import. Is there any documentation on how to parse the Image source field from an email import? Specifically, I am trying to parse out the "From" email address.

    0

Please sign in to leave a comment.