<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using mtime from tFileProperties to rename a file in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214100#M11087</link>
    <description>That's perfect, thank you. Using this I've managed to incorporate it into my job and it works fine. Many thanks</description>
    <pubDate>Wed, 28 Aug 2019 14:24:07 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-28T14:24:07Z</dc:date>
    <item>
      <title>Using mtime from tFileProperties to rename a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214098#M11085</link>
      <description>&lt;P&gt;I have a job which runs daily against some source files, with the ultimate output being a CSV file.&amp;nbsp; Each day, when the job runs, it renames the CSV, and puts the current date into the filename using this bit of code:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;"Filename_"+TalendDate.formatDate("ddMMyyyy",TalendDate.getCurrentDate())+".csv"&lt;/PRE&gt; 
&lt;P&gt;However, what I would like to do instead, is use tFileProperties to get the modified time of the file (mtime), and convert that into the string to use in the filename instead.&amp;nbsp; This is where I am struggling.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So I load the file into the &lt;STRONG&gt;tFileProperties&lt;/STRONG&gt; component&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I then grab the mtime value and created a variable called "&lt;STRONG&gt;stringdate&lt;/STRONG&gt;" in my tMap to convert it to &lt;STRONG&gt;ddmmyyyy&lt;/STRONG&gt; using this code:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;new java.util.Date((long)(row1.mtime*1000)/1000)&lt;/PRE&gt; 
&lt;P&gt;Outputted on its own, if the date was 27th August 2019, this then outputs &lt;STRONG&gt;27082019&lt;/STRONG&gt; as the result, which is exactly what I want.&amp;nbsp; However, this is in date format, so to add it to my filename it needs to be converted into a simple 8 digit string.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In my tFileCopy where I create the copy of the file and rename it, I use this code.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;"Filename_" +  Var.stringdate + ".csv"&lt;/PRE&gt; 
&lt;P&gt;However the result isn't "&lt;STRONG&gt;Filename_27082019.csv&lt;/STRONG&gt;", instead it is "&lt;STRONG&gt;Filename_Tue Aug 27 09:09:46 BST 2019.csv&lt;/STRONG&gt;"&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;How do I get around this?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:51:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214098#M11085</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-11-16T04:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: Using mtime from tFileProperties to rename a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214099#M11086</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;The most easy way is to use&amp;nbsp;mtime_string value to do the operation. Please refer the screenshots below for a sample file.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 766px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M7Ep.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/128038i58BB93E6F3356846/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M7Ep.png" alt="0683p000009M7Ep.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;You can add the transformations in the tMap as shown below.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="image.png" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009M7DJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/153061iA44B0CC75E1830B5/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009M7DJ.png" alt="0683p000009M7DJ.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;date_string -&amp;gt; TalendDate.formatDate("ddMMyyyy",TalendDate.parseDate("EEE MMM dd HH:mm:ss zzz yyyy",row1.mtime_string)) 

filename_bfr_extn -&amp;gt; row1.basename.substring(0, row1.basename.indexOf(".")) 

filename_aft_extn -&amp;gt; row1.basename.substring(row1.basename.indexOf(".")+1,row1.basename.length() ) 

output_file_name -&amp;gt; Var.filename_bfr_extn +"_"+Var.date_string  +"."+Var.filename_aft_extn &lt;/PRE&gt; 
&lt;P&gt;I hope I have answered your query. Please spare a second to mark the topic as resolved. Kudos will be bonus!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Warm Regards,&lt;BR /&gt;Nikhil Thampi&lt;/P&gt; 
&lt;P&gt;Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Aug 2019 16:44:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214099#M11086</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-27T16:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using mtime from tFileProperties to rename a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214100#M11087</link>
      <description>That's perfect, thank you. Using this I've managed to incorporate it into my job and it works fine. Many thanks</description>
      <pubDate>Wed, 28 Aug 2019 14:24:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214100#M11087</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-28T14:24:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using mtime from tFileProperties to rename a file</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214101#M11088</link>
      <description>&lt;P&gt;I know this is an old post but I am trying to do something similar.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How did you get to use the tMap variable in your tFileCopy component? &lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2023 22:08:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-mtime-from-tFileProperties-to-rename-a-file/m-p/2214101#M11088</guid>
      <dc:creator>lec86042</dc:creator>
      <dc:date>2023-02-03T22:08:06Z</dc:date>
    </item>
  </channel>
</rss>

