Skip to main content
Hi,

 

 

I would like to set the folder name of the source file to a published parameter, so I can use the folder name in the output directory filepath.

 

 

I have found in another post, the following TCL script for returning a filepath:

 

 

return efile dirname $FME_MacroValues(SourceDataset_SHAPE)]

 

 

Can someone please tell me how to amend this script so that it returns only the folder name not the whole directory? Or if the TCL option is not possible, any other ideas on using the folder name in the output file path?

 

 

(btw, I manage to extract the folder name within the workbench and set it to a published parameter, but the workbench still asks me for the published parameter when I run it, so it isn't working. I'm assuming this is because the output directory needs to be set at the start of the workbench so because I set the published parameter within the workbench it is too late).

 

 

Thanks,
Hi,

 

 

Have a look at the directory and file pathnames reader, for source properties.

 

If you managed to extract the forlder name, why use it as a published parameter and not an attribute value?
Hi,

 

 

The "file" command with "split" option returns a list containing components of the path string. The folder name will be the second element from the last  if a file full path was set to the argument.

 

The direct answer to your question may be:

 

-----

 

return rlindex lfile split $FME_MacroValues(SourceDataset_SHAPE)] end-1]

 

-----

 

 

Takashi
Hi Takashi,

 

 

I tried your script but I get the following error:

 

 

Starting translation...

 

 

INCLUDE -- failed to evaluate TCL expression `proc ParamFunc {} {

 

 upvar FME_MacroValues FME_MacroValues

 

return plindex file split $FME_MacroValues(SourceDataset_SHAPE)] end-1]

 

}

 

puts "MACRO OUT ;ParamFunc]"

 

' -- can't read "FME_MacroValues(SourceDataset_SHAPE)": no such element in array

 

    while executing

 

file split $FME_MacroValues(SourceDataset_SHAPE)

 

    (procedure "ParamFunc" line 3)

 

    invoked from within

 

ParamFunc

 

    invoked from within

 

puts "MACRO OUT nParamFunc]"

 

Program Terminating

 

 

Translation FAILED.

 

 

 

 
Itay, how do I use the attribute value to create a folder to send the output into? Can I set it somehow in "Fan out by Attribute"?
Ah I see I can Fan Out on the folder name attribute in the Navigator window!
Have you defined a user parameter named "SourceDataset_SHAPE" before the Tcl parameter definition?
you can fan out on writer under advanced (navigator window). For this you can use attributes created in the workspace.

 

 

This is very handy to create folders with subfolders with partitionised files based on one or more attributes of some feature/layer. For latter u can combine the DATAset fanout (in Navigator) with the feature-type fanout (in workspace)

Reply