Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm downloading multiple files from an API, and I'm getting a really long filename from the source, something like:
10102022-80137.csv?AccessKeyId=[long key]&Expires=[long date]&Signature=[long guid]
Is there a way to remove everything after the "?" for each filename so I'm just ending up with a clean "10102022-80137.csv" filename? I'm looking at using tfileList - tFileCopy but I'm struggling with the syntax to rename the filename by removing everything after '.csv'.
Let's assume that your filename is a variable called "filename". You can change that value to remove everything after the "?" with this code....
filename = filename.substring(0,filename.indexOf('?'));
How you use this will depend on how you are working with the file.
Let's assume that your filename is a variable called "filename". You can change that value to remove everything after the "?" with this code....
filename = filename.substring(0,filename.indexOf('?'));
How you use this will depend on how you are working with the file.
Thanks @Richard Hall - I appreciate it. Would I need to use a variable for the filename to do this or can I use a version of this 'inline' in the Destination filename field of the tFileCopy component view?
You can use the Rename switch to set the filename to be renamed and the Destination Filename field to place your code in there to rename the file. Your filename will need to be held in a variable. You can get the filename from the tFileList globalMap values.