cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Curly brackets in filename

Sahil
Contributor

Hi,
I am using Multi File reader snap but is not picking correctly filename if it has curly brackets.
filename is like: abcd{334-ffg-gg}.xml

How to handle these kind of schenarios.

17 REPLIES 17

Directory:
$[โ€œcontent-locationโ€].substring(0, $[โ€œcontent-locationโ€].lastIndexOf(โ€œ/โ€) + 1)
File filter:
$[โ€œcontent-locationโ€].substring($[โ€œcontent-locationโ€].lastIndexOf(โ€œ/โ€) + 1).replaceAll(" โ€œ,โ€%20")

@Sahil

I believe this is happening because of your curly brackets in your file name because the โ€œFile filterโ€ field I think it is using a regex pattern to search for the file. You need to escape the special characters in the file name. To do this you can use the following expression:

$filename.replace(/\W/g, (matched) => "\\".concat(matched))

The \W regex pattern here will search for all non-word characters in your string. Then with the (matched) function we target those non-word characters and we add the string "\\" before the special character to escape it. After this the search criteria will be: 'abcd\{334\-ffg\-gg\}\.xml'
In your case the expression would be:

$["content-location"].substring($["content-location"].lastIndexOf("/") + 1).replaceAll(" ","%20").replace(/\W/g, (matched) => "\\".concat(matched))

Hi, still ile size($[โ€œSize (in bytes)โ€]), date($[โ€œUpdate dateโ€]), path ($Path) coming as null.

did you try at your end? has it worked for you?

They are good on my end.
image

You can get the file size from content-length header from the file reader as well. Iโ€™m not really sure why these values are null in your case. Are you reading from an SFTP location ? Can you share the data before/after the Directory Browser ?

Hi,How do I get size, date, path from content-length header ?
what is the expression to use in mapper?