Skip to main content
Solved

Copying folder structure only with FileCopy ?

  • August 5, 2025
  • 3 replies
  • 83 views

tsirkuse
Contributor
Forum|alt.badge.img+3

Hello,

I am looking for additional insights on File Copy

  • Is it possible to copy folder structure without copying files inside ? How do I set the writer ?
  • What is the filecopy_type parameter ? and what are it’s possible values ? The parameter exists on the writer but I can’t find any information.

Thank you

 

Best answer by geomancer

You can also use SystemCaller, and invoke xcopy (of robocopy) there.
With xcopy use something like

xcopy "c:\temp\MyOriginalFolder\" "c:\temp\MyCopyFolder\" /t/e

Use /t to copy only the folder structure, not the files
Use /e to include empty folders

 

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.

3 replies

takashi
Celebrity
  • August 5, 2025

Hi ​@tsirkuse ,

I don't think that there is any option to copy only folder structure with File Copy writer unfortunately.

However, Python scripting might help you. For example, this script defined in a PythonCaller creates the same folder structure as the subfolders of “_source_folder” under “_destination_folder”.

import fme
import fmeobjects, os

class DirectoryCopier(object):
def __init__(self):
pass

def input(self, feature: fmeobjects.FMEFeature):
def copy_dirs(src, dst):
with os.scandir(src) as iter:
for entry in iter:
if os.path.isdir(entry.path):
dir = os.path.join(dst, entry.name)
os.makedirs(dir)
copy_dirs(entry.path, dir)

src = feature.getAttribute('_source_folder')
dst = feature.getAttribute('_destination_folder')
copy_dirs(src, dst)
self.pyoutput(feature)

def has_support_for(self, support_type: int):
return support_type == fmeobjects.FME_SUPPORT_FEATURE_TABLE_SHIM

def process_group(self):
pass

def close(self):
pass

 


hkingsbury
Celebrity
Forum|alt.badge.img+64
  • Celebrity
  • August 6, 2025

You could use the Directory and File Pathnames reader to read only the folders, then write a blank text file to the lowest folders (to create all the higher folders in the tree), then go through a delete the blank text files.

In my view, ​the approach @takashi outlined would be what I’d choose unless overarching policies blocked the use of Python


geomancer
Evangelist
Forum|alt.badge.img+59
  • Evangelist
  • Best Answer
  • August 7, 2025

You can also use SystemCaller, and invoke xcopy (of robocopy) there.
With xcopy use something like

xcopy "c:\temp\MyOriginalFolder\" "c:\temp\MyCopyFolder\" /t/e

Use /t to copy only the folder structure, not the files
Use /e to include empty folders