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?