Hitachi Vantara Pentaho Community Forums
Results 1 to 4 of 4

Thread: HASH Value Creation in Pentaho

  1. #1

    Default change file in folder based on another input field value

    Dear All,

    I am looking for some file processing option to do the following:

    Input data:
    Name of product Image location checksum
    Watch D:\Users\rparuchuri\Desktop\Test\Images1\watch_20151209_182946.jpg 26976b316af01b456084
    Diary D:\Users\rparuchuri\Desktop\Test\Images1\Diary_20151209_182946.jpg 73ec67a4bb4e68a8

    I want to replace the names of the images under “D:\Users\rparuchuri\Desktop\Test\Images1\” with the ‘checksum’ field. So the output should look like this:

    Outputdata:
    Name of product Image location checksum
    Watch D:\Users\rparuchuri\Desktop\Test\Images1\26976b316af01b456084.jpg 26976b316af01b456084
    Diary D:\Users\rparuchuri\Desktop\Test\Images1\73ec67a4bb4e68a8.jpg 73ec67a4bb4e68a8


    Can someone help me which file processing function to use? the main help I need here is to rename the the images under the folder
    D:\Users\rparuchuri\Desktop\Test\Images1
    ?
    Last edited by theperk2; 12-14-2015 at 08:52 AM.

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You seem to have two problems here with an old absolute filename and a new basename for that file.

    A User-Defined-Java -Expression step can be used to assemble the new filename:
    Code:
    FilenameUtils.concat(FilenameUtils.getFullPath(oldName), checkSum + FilenameUtils.EXTENSION_SEPARATOR_STR + FilenameUtils.getExtension(oldName))
    FilenameUtils must be written as org.apache.commons.io.FilenameUtils, of course.

    The actual renaming (moving) can be done using a Process-Files step, then.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Apr 2008
    Posts
    4,696

    Default

    So let me get this clearly...

    You want to:
    1) Get all the filenames in D:\Users\rparuchuri\Desktop\Test\Images1
    2) Calculate the checksum on each file
    3) Move each file to the same directory, with checksum value as their names.

    I think that if you dig, you'll find steps in PDI to do each of those things.

  4. #4

    Default

    Hallo Marabu,

    when I use the following Java expression:

    org.apache.commons.io.FilenameUtils.concat(org.apache.commons.io.FilenameUtils.getFullPath(URL), checkSum + org.apache.commons.io.FilenameUtils.EXTENSION_SEPARATOR_STR + org.apache.commons.io.FilenameUtils.getExtension(URL))

    then I get the error: unknown variable or Type Checksum.

    do I need to any extra stuff here?
    ----------------------------------
    Hi Gutkez,

    here is the process what I need:

    1) convert the file names from image1 in D:\Users\rparuchuri\Desktop\Test\Images1 to chesum and rename image1 with checksum
    2) if the image 2 with the same image content as image 1 is Present again (this I can only compare based on checksum conversion value ) then delete such images


    regards,
    Rama
    3) Move each file to the same directory, with checksum value as their names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.