Skip to main content
Solved

Can't read files in folders with brackets with Directory and File Pathnames reader.

  • November 9, 2016
  • 5 replies
  • 245 views

nielsgerrits
VIP
Forum|alt.badge.img+62

Dear community,

When I try to scan a directory where the folder contains brackets the files in this folder are not being read.

I can imagine why brackets cause problems but sadly this data is often external input. Does a workaround exist? (Other than scanning folders for brackets and edit the folders.)

folder:

output:

 

path_windows

 

D:\\tmp\\New folder (25)\\input\\test

 

D:\\tmp\\New folder (25)\\input\\[test]

 

D:\\tmp\\New folder (25)\\input\\test\\data.txt

 

D:\\tmp\\New folder (25)\\input\\test\\[data].txt

missing output:

 

D:\\tmp\\New folder (25)\\input\\[test]\\data.txt

 

D:\\tmp\\New folder (25)\\input\\[test]\\[data].txt

Best answer by mark2atsafe

OK, I see an update to our documentation to cover this scenario. It says...

C:[data]Sometimes specifying the glob pattern syntax can conflict with the special characters in the path. In this case, the directory contains [] characters and by default will be misinterpreted as a glob pattern.

This case can be read correctly by removing the default glob pattern ‘*’ and leaving the Path Filter empty. This will disable glob interpretation and the path will be interpreted literally.

I hope that helps. These brackets are a special case because of how they are usually used for a pattern, so I'm hopeful no other special characters should cause similar problems.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • November 9, 2016

Hoi @nielsgerrits I dont think a workaround is possible with the Files and Directory Reader, so some kind of manipulation beforehand of the folder and file names will be probably needed.

Probably a python script can be used for that, but also good old DOS (dir and rename) can be used with the SystemCaller.

Hope this helps

removebracketsfromfoldername.fmw


nielsgerrits
VIP
Forum|alt.badge.img+62

Hoi @nielsgerrits I dont think a workaround is possible with the Files and Directory Reader, so some kind of manipulation beforehand of the folder and file names will be probably needed.

Probably a python script can be used for that, but also good old DOS (dir and rename) can be used with the SystemCaller.

Hope this helps

removebracketsfromfoldername.fmw

Nice one, SystemCaller is getting a favorite transformer.

mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • November 9, 2016
I can't think of a workaround, but I have filed this issue with our developers as PR#73743

 

If it's a small fix then maybe we'll be able to get it into FME2017 (no guarantees though)

 


nielsgerrits
VIP
Forum|alt.badge.img+62
  • Author
  • November 11, 2016
Thanks @Mark2AtSafe, one of the reasons for me to post these isolated reproducers is to give you guys input for making even better software. :-) Wondered if a list of characters causing this problem is available so I could test input folders? I could generate something myself with ascii codes but if available allready...

 

 


mark2atsafe
Safer
Forum|alt.badge.img+59
  • Safer
  • Best Answer
  • November 23, 2016

OK, I see an update to our documentation to cover this scenario. It says...

C:[data]Sometimes specifying the glob pattern syntax can conflict with the special characters in the path. In this case, the directory contains [] characters and by default will be misinterpreted as a glob pattern.

This case can be read correctly by removing the default glob pattern ‘*’ and leaving the Path Filter empty. This will disable glob interpretation and the path will be interpreted literally.

I hope that helps. These brackets are a special case because of how they are usually used for a pattern, so I'm hopeful no other special characters should cause similar problems.