Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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.
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