Curly brackets in filename

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.

Hi @Sahil,

What do you mean by “not picking correctly the filename if it has curly brackets” ? Does it throw any errors ? I’m pretty sure that you can read a file with a name like ‘abcd{334-ffg-gg}.xml’ without any problems.

I agree:

Do you happen to have the expression toggle (the button with = sign) selected?

My pipeline is like below:-
and use the content-location & content-disposition in child pipeline.
But it is passing file as abcd_334-ffg-gg_.xml

@bojanvelevski ,
response here.

@dmiller , response below.


If you are trying to get the name of the file in the child pipeline, you can pass the content-location header. I don’t know where are you reading the file from, but if it’s SLDB, the header value should look like this:
And if you want to get the filename only, you can use this expression: $['content-location'].split("/")[$['content-location'].split("/").length - 1] this will return the name of the file.

1 Like

Did you check “content-disposition”. its coming wrong there.

Yes I did check it, it is coming like you said with "_" instead of {}
That’s why I said you can use the content location to get the filename.

In the child pipeline I have directory browser and after that I have a mpper to collect file size($[“Size (in bytes)”]), date($[“Update date”]), path ($Path)
and all are coming null.

And what is the search criteria in the directory browser ? What value do you pass in there ?

$[“content-location”].substring(0, $[“content-location”].lastIndexOf("/") + 1)
File filter:
$[“content-location”].substring($[“content-location”].lastIndexOf("/") + 1).replaceAll(" “,”%20")


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.

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?

After the Multi File Reader snap, you get the headers from the file that you are reading.
For Size in bytes you can use the content-length header.
For Update date use the last-modified header.
And for the Path you can take the content-location header.

1 Like