Solved

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

  • 9 November 2016
  • 5 replies
  • 44 views

Userlevel 6
Badge +32

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
icon

Best answer by mark2atsafe 23 November 2016, 22:36

View original

5 replies

Badge +16

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

Userlevel 6
Badge +32

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.
Userlevel 4
Badge +25
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)

 

Userlevel 6
Badge +32
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...

 

 

Userlevel 4
Badge +25

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.

Reply