Question

Create Empty Folders

  • 10 July 2014
  • 6 replies
  • 59 views

Badge +1
Hi,

 

 

I am working on Win 7 machine with FME 64x. Here is a query for no-spatial purpose. I want to create a list of empty folders from a workbench.

 

 

Example-

 

 

I have a Local drive 'D' and I want to create folders like-

 

 

01_Source

 

02_Data

 

03_FME

 

04_ArcGIS

 

05_Erdas

 

06_AOI

 

 

and subfolders moreover -

 

 

01_Source\\Directory\\File

 

06_Erdas\\POI_Image

 

 

 

Is it possible using FME.

 

 

Thanks :)

6 replies

Userlevel 2
Badge +17
Hi Shivam,

 

 

I think Python script is a quick way. For example:

 

-----

 

import fmeobjects, os

 

def processFeature(feature):

 

    dir = feature.getAttribute('directory')

 

    if not os.path.exists(dir):

 

        os.makedirs(dir)

 

-----

 

 

Takashi
Badge +1
Hi,

 

 

Thank you Takashi for the reply. I did check your method for my question, but could not go through, I am a little low in coding actually.

 

I have got a method for the same.

 

We can use the "Creator" transformer and use "file copy" as the writer. A very simple workbench is displayed below. :).
Userlevel 2
Badge +17
Indeed that works :)

 

If you need to create many folders, create a workspace like this:

 

 

Then, you can run it repeatedly via another workspace having a WorkspaceRunner.

 

 

Badge +1
It seems that workspacerunner can do my job, as I need to run bulk workspaces in one go.

 

But, I am getting trouble using this. What i/p and o/p should I give to use this transformer?

 

Thanks :)
Userlevel 2
Badge +17
Solution depends on how you have folder paths information.

 

Just one example, if you have a text file containing folder paths line by line:

 

-----

 

01_Source\\Directory\\File

 

06_Erdas\\POI_Image

 

.....

 

-----

 

you can read the file with the Text File reader, and send every feature to the WorkspaceRunner (pass "text_line_data" to Destination File Copy Directory parameter).
Userlevel 2
Badge +17
correction.

 

-----

 

D:\\01_Source\\Directory\\File

 

D:\\06_Erdas\\POI_Image

 

.....

 

-----

Reply