I'm trying to remove the file extension name.
for example. the file name is user.txt.temp and i want to remove the .temp before i upload it. the file name should be user.txt
Assuming that you will have more than one period (.) for the file name, you can use lastIndexOf to find the last period and remove all that appears after the last period. You can use the below script in your custom scripting.
var input = 'myfile.png.temp.test';var output = input.substr(0, input.lastIndexOf('.'));
Hope this helps!
Thank you for the reply.
Sorry. Im new to this. The scenario is I got files from my local disk. I'm going to remove the .temp on all the filenames. Then send it to the FTP server.
Example of the files:
Then the output should be:
What is your use case? Is it just pull files from disk and trim the extensions or do you perform some manipulation on the file content?
If you pull more files and just stripping off the file extensions...
1. Pull files from Disk
2. Bring in flow control shape and run each document independently
3. Then assign the document property of File Name to a variable
4. Bring in dummy map and use custom scripting using the code I shared to strip off extensions
5. After the map assign the document property back to your FTP File Name
I done differently. But will do your method for more reference. hehe.
What I did was:
1. Flow Control
2. Msg Shape
3. Business rules Shape (with function for string to eliminate the extension name)
4. Then upload it to FTP
Thank you so much sir. This will be a good reference.
Of course for any issue we have multiple solutions, whatever fits and easy go ahead. I am glad you are able to find another way. That is the way we do!
Retrieving data ...