Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
JKnoll18
Contributor
Contributor

Renaming multiple files by removing everything after a delimiter

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'.

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable

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.

View solution in original post

3 Replies
Anonymous
Not applicable

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.

JKnoll18
Contributor
Contributor
Author

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?

Anonymous
Not applicable

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.