Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
lec86042
Contributor
Contributor

Rename xls file with the documents Last Modified Date

Hello,

I have 75 spreadsheet (workbooks) that need to be renamed with the last modified date (it woudl be awesome to add the person's name who modified as well). So far this is what I have:

tFileList >> tFileProperties >> tFilterColumns (only need mtime) >> tMap (use to convert mtime to "yyyy-MM-dd") >> tFileCopy (would like to rename file with mtime)

So file 000ff1.xls would be renamed 000ff1_2022-01-29.xls

I just dont know how to make a "global variable" that can be used across any components in my job design.

Please let me know if I need to add more details.

Labels (4)
1 Reply
Anonymous
Not applicable

Hi

tFilterColumns: need mtime and basename

tMap: convert the mtime to a Date and has an output table that contains two columns: basename and last_modified_date,

After tMap, you can store the date to a global variable on a tJavaRow for used later, eg:

...tMap--out1--tJavaRow--oncomponentOK--tFileCopy

on tJavaRow:

globalMap.put("last_modified_date",TalendDate.formatDate("yyyy-MM-dd",input_row.columnName));

String basename=input_row.basename;

String filename=basename.substring(0, basename.lastIndexOf("."))

globalMap.put("filename",filename);

on tFileCopy, you can access the global variable like this:

"D:/file/"+(String)globalMap.get("filename")+"_"+(String)globalMap.get("last_modified_date")+".xls"

 

Please try and let me know if you have any questions.

 

Regards

Shong