Skip to main content
Solved

How do I create a folder whose name is based on the date the Workbench is run?

  • March 1, 2018
  • 13 replies
  • 249 views

Hi all,

Just taking my first steps with FME. I am using the FTPCaller to download two .zip files that are provided on a weekly basis. When I specify an existing folder everything works fine. However, I'd actually like to download the .zips to a folder whose name is actually the date on which the download took place. However, when I try and incorporate this into the FTPCaller's 'Target File' path (e.g. C:\\Downloads\\@DateTimeFormat(@DateTimeNow(),%Y_%m_%d)\\@filename) the translation fails as the file is unable to be written.

If the FTPCaller is unable to create a destination folder on the fly, how would I go about creating the folder?

Any suggestions appreciated!

Thanks!!

Best answer by fmelizard

The FTPCaller should make the directory for you, so that is a bug on our side which we'll get to.

In the meantime, @jdh is right, Python is the way to go. Turns out @takashi has shown us how a while ago, so I put together a sample that should help you get going: testdirectorymaker.fmw

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.

13 replies

jdh
Contributor
Forum|alt.badge.img+36
  • Contributor
  • 2001 replies
  • March 1, 2018

You can use either the SystemCaller, or a PythonCaller to make the directory prior to the FTPCaller.


taojunabc
Participant
Forum|alt.badge.img+6
  • Participant
  • 108 replies
  • March 3, 2018

Because there is no such funciton as @filename in FME?so an error occurs.

C:\\Downloads\\@DateTimeFormat(@DateTimeNow(),%Y_%m_%d)\\@filename


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • Best Answer
  • March 4, 2018

The FTPCaller should make the directory for you, so that is a bug on our side which we'll get to.

In the meantime, @jdh is right, Python is the way to go. Turns out @takashi has shown us how a while ago, so I put together a sample that should help you get going: testdirectorymaker.fmw


  • Author
  • 3 replies
  • March 6, 2018

You can use either the SystemCaller, or a PythonCaller to make the directory prior to the FTPCaller.

Many thanks JDH. I initially used the system caller to create the folders, but have switched to the python caller so that I can create the folders and unzip the downloads at the same time.

 

 

Thanks again!

 

 


  • Author
  • 3 replies
  • March 6, 2018

The FTPCaller should make the directory for you, so that is a bug on our side which we'll get to.

In the meantime, @jdh is right, Python is the way to go. Turns out @takashi has shown us how a while ago, so I put together a sample that should help you get going: testdirectorymaker.fmw

Thanks Dale - the Python caller worked a treat.

 


  • Author
  • 3 replies
  • March 6, 2018

Because there is no such funciton as @filename in FME?so an error occurs.

C:\\Downloads\\@DateTimeFormat(@DateTimeNow(),%Y_%m_%d)\\@filename

Hi taojunabc - sorry this was a typo on my part. It should have been ...\\@value(filename). I resolved the issue using Python caller. Thanks for your help.

 

 


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • October 22, 2019

Took a bit longer than we hoped, but for the record, this is fixed as of FME 2019.2 build 19790 and will be in FME 2020 betas with builds later than 20110.


freddy17
Contributor
Forum|alt.badge.img+8
  • Contributor
  • 28 replies
  • June 24, 2020

The FTPCaller should make the directory for you, so that is a bug on our side which we'll get to.

In the meantime, @jdh is right, Python is the way to go. Turns out @takashi has shown us how a while ago, so I put together a sample that should help you get going: testdirectorymaker.fmw

Thank you Dale, this worked well. I just have a follow up question. If you set the folders with the Python Caller, how can you set the Dataset Source Folder and File pathname of new Writers? Say you would like to export your fme data to an Excel Writer that you would like to add to your newly created Folder?

I have attempted to use Feature merger and been messing around with the Dynamic Schema, but cant seem to get it working.

 

Thanks in advance


  • 7 replies
  • April 7, 2021

The FTPCaller should make the directory for you, so that is a bug on our side which we'll get to.

In the meantime, @jdh is right, Python is the way to go. Turns out @takashi has shown us how a while ago, so I put together a sample that should help you get going: testdirectorymaker.fmw

@Dale Lutz​ I wonder if it has been to long to ask if you could repost the workspace? This is a python caller sample that would greatly help me.


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • April 29, 2021

Looks like my attachment got dropped from the previous answer, but I've re-uploaded it below.


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • April 29, 2021

@Dale Lutz​ I wonder if it has been to long to ask if you could repost the workspace? This is a python caller sample that would greatly help me.

Yes, it looks like it was lost -- see attached.


fmelizard
Safer
Forum|alt.badge.img+20
  • Safer
  • 3719 replies
  • April 29, 2021

Thank you Dale, this worked well. I just have a follow up question. If you set the folders with the Python Caller, how can you set the Dataset Source Folder and File pathname of new Writers? Say you would like to export your fme data to an Excel Writer that you would like to add to your newly created Folder?

I have attempted to use Feature merger and been messing around with the Dynamic Schema, but cant seem to get it working.

 

Thanks in advance

Sorry for not noticing this before -- the way to proceed would be to use a FeatureWriter after the PythonCaller. But depending on exactly what you want to do, things are either a bit more complex, or simple, depending on your point of view.

 

For one thing, the Excel writer will create the directory for you -- so there is no need to use the PythonCaller. If you give the Excel writer "C:\\Path\\To\\My\\File.xlsx" -- it will make all those directories if they don't already exist. So there is no need to make use of the python in this case.

 

If this is still causing you trouble, please post a fresh new question with details of your scenario (esp what the input is) and the voices of the FME community will chime in. Pretty sure we can solve this, just a matter of knowing the details....


hlouie
Contributor
Forum|alt.badge.img+16
  • Contributor
  • 33 replies
  • April 29, 2022

I've been doing this to create new "directories" for downloading sftp files

FTPCaller_Creating New Directory_working