Reading and writing the image path list to the ImageDetails Excel file

Perform the following steps:

  1. Since we only need the image files, we need to check whether the files have a certain extension – we will only pass JPG or PNG images in this project. To inspect the file properties, create a new variable called strFileInfo of the FileInfo type and set the scope to the Try-Catch block.
  2. Let's also add a counter variable called intCounter of the Int32 type and set the scope to Try-Catch as well. We will be using this variable to loop through the Excel cells. Go ahead and set the default value for this variable to "2" since we want to start from the second row in Excel.
  3. Now that we have the variables, let's use the Assign activity to pass the file information (New FileInfo(item.ToString)) value to the strFileInfo variable we just created. Now, we are ready to inspect the variable for file information. Here is what your For Each part of the workflow should look like:

  1. Let's add some conditions so that only image files are extracted. For that, we will add an If block with the condition set to strFileInfo.Extension =".jpg" Or strFileInfo.Extension =".png".
The Google Cloud Vision API supports images of different types too. Please go ahead and try adding different image types, such as .img, .tiff, and so on, as you need to in order to test out this API.
  1. In the Then part of the If block, write the file path to the Excel cells in column A. To do that, we will use the Write Cell activity (App Integration | Excel | Write Cell ). For this activity, update the following properties:
    • Set the Range property to "A"+intCounter.ToString.
    • Set Value to strFileInfo.FullName.

As you can see, we set the range for Column with the incrementing counter for the rows. The Value would be the full file path of the image files. 

  1. Since we want to loop, let's add an Assign activity to increment intCounter. To do so, assign intCounter to intCounter +1. Your workflow should look like this:

  1. Now that we have written the ImageDetails.xlsx file with the image file paths, we need to add a Log message with Log Level set to Info and a Message that states "Image list was successfully retrieved". Let's add this outside the Excel application scope and within the Try block, as shown in the following screenshot:

With that, we have completed our BuildExcelList sequence. Let's finish this by handling any exceptions using the Catch block.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.73.77