Skip to main content

Hi

I have a large number of files that are formatted like so:

AA0001

AA0002

AA0003

AB0001

AB0002

AB0003

AC0001

AC0002

AC0003

Is there a way to take all of these files and sort them into their respective folders using the text prefix, for example all the AA files go into a folder call AA, the AB's in AB and AC's into AC?

I have a TestFilter that will do using a @Value(fme_basename) CONTAINS Test Condition for each text prefix, the output for each of these going to it's own writer, and this does work however it seems messy. Is there a better way to do this?

Thanks.

You can use substring extractor to pull out x number of letters from fme_basename (after exposing it). This creates an attribute called _substring which you can then fanout on


You can use the "Directory and File Path" reader to read all file names in the folder.

Then feed these (based on the required sub string) to a "File Copy" writer to copy (or move) the files to different folders.

This way you do not need to read the contents of the files (which you do by using the fme_basename).


You can use the "Directory and File Path" reader to read all file names in the folder.

Then feed these (based on the required sub string) to a "File Copy" writer to copy (or move) the files to different folders.

This way you do not need to read the contents of the files (which you do by using the fme_basename).

So I've done this but it's just making the folders, not copying any of the files across. What am I missing?

 

 


So I've done this but it's just making the folders, not copying any of the files across. What am I missing?

 

 

Can you post a workspace or at least a screenshot? It's going to be hard to diagnose without. Any messages in the log window give a clue?

 

 


Question: do all the folders exist?

 

 


So I've done this but it's just making the folders, not copying any of the files across. What am I missing?

 

 

It's difficult to diagnose without information about how you've designed the workspace, but I suppose most likely you have not connected source file path attribute between the source side and the writer feature type.

 


It's difficult to diagnose without information about how you've designed the workspace, but I suppose most likely you have not connected source file path attribute between the source side and the writer feature type.

 

This is what I have so far. It creates the folders that I want but
doesn't actually copy any files over. I have managed to get it to copy
all the files into each of the folders but that's not much use since it
just duplicates them, it doesn't actually sort them.

 

 


This is what I have so far. It creates the folders that I want but
doesn't actually copy any files over. I have managed to get it to copy
all the files into each of the folders but that's not much use since it
just duplicates them, it doesn't actually sort them.

 

 

You have to inform the File Copy writer the path of source files to be copied. Try connecting between "path_unix" (or "path_windows") of the source side and "filecopy_source_dataset" of the File Copy writer feature type.

 


You need to create the attributes for the filecopy writer, something like the above will copy the relevant files to subfolders in the same parent folder. If you want to copy them somewhere else you will need to do a bit more manipulation to create the correct destination


This is what I have so far. It creates the folders that I want but
doesn't actually copy any files over. I have managed to get it to copy
all the files into each of the folders but that's not much use since it
just duplicates them, it doesn't actually sort them.

 

 

This image illustrates my intention. There could be other possible configurations.

 

 


This is what I have so far. It creates the folders that I want but
doesn't actually copy any files over. I have managed to get it to copy
all the files into each of the folders but that's not much use since it
just duplicates them, it doesn't actually sort them.

 

 

Thank you Takashi, that's what I was looking for, it copied everything to the correct folders. I knew it was something simple I was just overlooking.

 

 


Reply