Hitachi Vantara Pentaho Community Forums
Results 1 to 16 of 16

Thread: how to rename files

  1. #1
    Join Date
    Dec 2007
    Posts
    3

    Default how to rename files

    Hello! I'm fairly new to using kettle and I'm creating a job. After the transformation is done, I want to move the CSV files to another location and then rename it. I have successfully moved the files and my problem is renaming it. I need to rename it with a unique name each time (preferably its filename + date) because there will be new CSV files with the same filenames that will be loaded into the same directory a while later.

    How can I do this.. There is no rename step....

    I tried using the Zip File step. It turned out ok. I zipped the files and moved it into a new directory. I also used the function that will automatically rename a file if a file with the same name exists. The filename looks like this:

    FILENAME_113025_30042005


    The 113025 indicates the hour, minutes and seconds, and the second part 042008 indicates the day and year. but why is there no month? The 30 shown before 042008 is the same as the minutes. I have done this a couple of times with the same result. Is there any significance as to why the month isn't shown and was replaced by the minute instead?

    Thanks...

  2. #2
    Join Date
    May 2006
    Posts
    4,882

    Default

    For the last question... yes someone made a mistake and used "mm" instead of "MM".
    Raise a defect at http://jira.pentaho.org/browse/JIRA

    Regards,
    Sven

  3. #3

    Default

    Hi,

    Thanks Sven, fix is in 3.1 and 2.5.3.
    It should be nice to have a "name unique" in "Copy files" job entry.

    Rgds

    Samatar

  4. #4
    Join Date
    Jun 2007
    Posts
    138

    Default rename existing file

    How to rename an existing file using transformation?

    I just want to change its extension form .txt to .load

    I m using kettle 2.5 transformation..Thanx in advance!
    Regards,
    kedar.mehta@tcs.com ,
    Tata consultancies Ltd

  5. #5
    Join Date
    May 2006
    Posts
    4,882

    Default

    Can't be done for the moment from a transformation via a dedicated step.

    For the moment you can do a copyFile/deleteFile in a javascript step, in a seperate transformation than the rest of your functionality.

    Regards,
    Sven

  6. #6
    Join Date
    Jun 2007
    Posts
    138

    Default Rename file

    hmmm...
    Good.

    Even if I do it in other transformation,I ll have to do it like Copy as Rename n Delete the older..

    Regards,
    kedar.mehta@tcs.com ,
    Tata consultancies Ltd

  7. #7

    Default Rename file

    I used CMD comand rename, for example:
    REN dir/file newfile

  8. #8

    Default

    if you are using Linux use shell script and move the files and rename them in the shell script , it is much faster than using pentaho file moving transformation ( i did some bench marking on this

    if you are using windows may be you can cmd line for renaming the files as said by carlos

  9. #9
    Join Date
    Mar 2010
    Posts
    23

    Default

    Hi, this is and oold thread but i was looking for something similar to rename a file within a job. Currently in version 4.01 there is not such an entry yet.

    I was abled to add an extension to a file (not change an existing one) using the Copy/Move entry and adding a date format like: '.extension' and unckeking the "add date before extension" option.

    maybe it be useful to know that you can add via date format something in the name of a file.

    hope it be helpful to someone

    Cheers

  10. #10
    Join Date
    Nov 1999
    Posts
    9,729

    Default

    The "Process Files" step allows you to move a series of files from one name to another. (essentially renaming)
    The "Move files" job entry allows you to move a single file without too much of a problem.

  11. #11
    Join Date
    Sep 2009
    Posts
    3

    Default

    Hi,

    probably this is not the right post but similar need.
    I want to rename a file just after put it by ftp.
    The only way I have to do it is by using ftp rename command, but this is not implemented actually.
    I need it because while transfering the resulting text file (time depend on file length and network speed) a remote process could read the file before the transfer ends, so it's safe to transfer the file with a different name (with a dot as prefix, it results hidden on Linux system) and then rename it with the real file name upon transfer completed.
    Thanks.

  12. #12
    Join Date
    Sep 2009
    Posts
    3

    Default

    Don't mind. I did it!

    The solution has been made developing a Job with the following steps:
    I used FTP Put to transfer the file with the temporary name.
    Then using a Rename File step to rename the destination file, but the magic is to use the VFS file definitions (source=ftp://userass@server/destination_dir/temp_file destination=ftp://userass@server/destination_dir/renamed_file)
    All the configurable pieces have been replaced with variables (user, pass, server, destination_dir, temp_file, renamed_file)
    Calling the job with proper variables set does the trick.

    Happy integration!

  13. #13
    Join Date
    Nov 2015
    Posts
    3

    Default

    Hi benhur9ph!.

    You could rename files with a transformation?. How is this possible?.

    Thanks regards.

    Jaz.

  14. #14
    Join Date
    Nov 2015
    Posts
    3

    Default

    hello!

    Firstly, sorry my english is bad.

    Please, could you help me?

    I want to rename .csv and has not worked the transformation. You succeeded?.

    Your case is very similar to mine. I work in the maritime area.

    Thanks in advance.

    Jaz.

  15. #15
    Join Date
    Apr 2008
    Posts
    1,771

    Default

    Hi.
    I think that you need to use a Copy or Move files step in order to rename them.
    Or use a Shell script with bat or bash.
    -- Mick --

  16. #16
    Join Date
    Nov 2015
    Posts
    3

    Default

    Done!.

    Thanks!!.

    Jaz.

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.