FME – Looping Through Directory to Use GDB with Current Date from Folder in FME BatchFile

batchfme-form

I created a batch file using the command line from the FME workspace and need to run it through a task scheduler. The file gdb is a parameter that needs to change in this batch file on every run. I am not sure if is there a way to loop through a folder and select the current gdb from the folder.

"C:\Program Files\FME\fme.exe" "D:\Workspace_features\Country_NEW_APM updates_FeaturesOnly.fmw" TRANSACTION_TYPE_GEODATABASE_SDE "VERSIONING" VERSION_GEODATABASE_SDE "DBO.SarahS_APM_edits_Country_006" geodb "G:\APM_DOWNLOADS\Country\Country_Bulk_2022-05-01_22-43-59\Country_Bulk_2022-05-01_22-43-59.gdb"

PAUSE

I have tried Workspace runner and I used Directory and path reader it works that way but we needed to run these workspaces through a task schedular and trigger these every morning as there are almost 15 markets to run every day.

If I use Python Creator and searches all gdb will I be able to put those task on the scheduler?

Best Answer

If I understand correctly, you want to:

  1. Get a list of all GDBs in a directory
  2. Sequentially process all of them using an FME process, something akin to a traditional loop in programming.

If those are true, to accomplish this without python is fairly simple.

Workspace Link

Setup Example: Assuming we have a folder called "GDBs" with ten FileGeodatabases inside.

enter image description here



Step 1: Create your workspace that processes the Geodatabases. For my example, its called GDBProcessor.fmw. Add an input parameter to dynamically pass file paths to reader:

  1. Type: File/URL
  2. Items to select: Geodatabase

enter image description here



Step 2: Link Parameter to Feature Reader enter image description here



Step 3: Now lets create a main workspace to call this GDBProcessor Workspace once for each of the ten GDB Inputs: Lets call this GDBProcessCaller.FMW. Here we are using a Directory and File Path name reader to read the Windows Path of each GDB in the main folder, so we end up with ten records. We pass these ten records with file paths to the Workspace runner, calling the GDBProcessor once for each input path, and passing the input path into the workspace via the parameter we created in step 1 enter image description here