Home Image-Pro Automation (Macros, Apps, Reports)

change filename after editing image

I struggle to find a way how to change a file name from "xyz" to "xyz_corrected".
I load image "original", then apply a 2d filter creating a new image.

The .name function allows me to define a string as the new file name, however I delete the original name.... while I actually would like to add the string "_corrected" to the end of the original file name.
.Name = "low_pass"

Best Answer

  • Accepted Answer
    Hi Diet,

    You can use doc1.FileName property to get the full file name of the original file and the System.IO function to get the name without extension, like this:

        Sub PrintDocName
            Dim doc1 As IMcDocument=ThisApplication.ActiveDocument
            Dim oldName As String=System.IO.Path.GetFileNameWithoutExtension(doc1.FileName)
        End Sub



  • I found a way using the below, however it calls the "orignal" name with the file type... so the result is "original_jpg_low pass". This works for me... but would there be any other function than doc1.name that only yields the name without file type (jpg)?

    Thanks a lot.
    Dim title1 As String
    With Adjust.ImageCommands.Duplicate(correct_)
                title1 = doc1.name + " low pass"
                .Name = title1

  • 2019-08-15-083714

    Diet --

    Below is a section of CODE from one of the APPS that I have written. 

    I believe if you review this and combine the information within with the information you and YURI have provided, you will have the solution to your challenge.

    I hope this information is helpful.

    -- Matt


                    'Find the extension on the image name
                    Dim MyIndex1 As Integer = _
                        InStrRev(Trim(textBox_FullExperimentLogFileName.text), ".")

                    'Build the full name for the txt file
                    Dim MyFullFileNameTifFile As String

                    If _
                        ( _
                        Trim(textBox_CurrentWellName.text) <> "" _
                        ) _

                            'USE THE NAME OF THE CURRENT WELL IN THE NAME
                            MyFullFileNameTifFile = _
                                Left(Trim(textBox_FullExperimentLogFileName.text), MyIndex1 - 1) & _
                                " -- " & _
                                AlcesNow () & _
                                " -- " & _
                                "WELL_" & _
                                textBox_CurrentWellName.text & _


                            'USE 000 IN THE NAME
                            MyFullFileNameTifFile = _
                                Left(Trim(textBox_FullExperimentLogFileName.text), MyIndex1 - 1) & _
                                " -- " & _
                                AlcesNow () & _
                                " -- " & _
                                "WELL_" & _
                                "000" & _

                        End If

                    'Save the active image in the appropriate TIF FILE
                    With Application.DocumentCommands.SaveAs(Nothing)
                        .FileName = _
                    End With
Sign In or Register to comment.