Skip to main content
Question

Dynamically create suffix to newly copied gdb

  • February 19, 2025
  • 7 replies
  • 56 views

joepk
Influencer
Forum|alt.badge.img+20
  • Influencer

Hi all,

I am using the Overwrite Existing Geodatabase/Template Geodatabase functionality:

This creates a new copy of my gdb with a “_yyyymmdd” suffix. 

However, if my users run this multiple times a day, they have to delete the output of the previous run.

I would prefer there to be a “_yyyymmdd_N” suffix, with N being incremented for every time the workspace has finished running that day.

What is the sleekest way to implement this?

 

I now have built something with a Path FeatureReader and a combination of Testers and StringConcatenators to filter out and manipulate the different filenames with either no suffix, a date suffix or a date+N suffix. Then FeatureJoiners to join the different path features into one:

It works but its bulky and it feels overengineered.

Any inputs?

 

Kind regards,

Joep

7 replies

redgeographics
Celebrity
Forum|alt.badge.img+47

Does it really have to be a consecutive number? Would, for example, an addition to hour-minute-second to the filename be sufficient? That’s a lot easier to achieve and unless you have multiple people running it at the same second it should be unique.


nielsgerrits
VIP
Forum|alt.badge.img+52
redgeographics wrote:

Does it really have to be a consecutive number? Would, for example, an addition to hour-minute-second to the filename be sufficient? That’s a lot easier to achieve and unless you have multiple people running it at the same second it should be unique.

This is how I solved it. 


joepk
Influencer
Forum|alt.badge.img+20
  • Author
  • Influencer
  • February 19, 2025

Hi guys, thx for the quick replies, yeah I've considered using _yyyymmddhhmmss or something similar as a suffix, but the (future) users I've talked to so far all said they'd appreciate _N. 


nielsgerrits
VIP
Forum|alt.badge.img+52

I would just make it a bit more readable. My default datetimestamp scripted parameter looks like this, works like a charm:

import datetime  return datetime.datetime.now().strftime("%Y_%m_%d__%H_%M_%S")


redgeographics
Celebrity
Forum|alt.badge.img+47
joepk wrote:

Hi guys, thx for the quick replies, yeah I've considered using _yyyymmddhhmmss or something similar as a suffix, but the (future) users I've talked to so far all said they'd appreciate _N. 

It has to run on Form, right? If it’d be Flow you could use the Job ID. They’re not consecutive per workspace, but they are unique and “simple”


joepk
Influencer
Forum|alt.badge.img+20
  • Author
  • Influencer
  • February 20, 2025
redgeographics wrote:
joepk wrote:

Hi guys, thx for the quick replies, yeah I've considered using _yyyymmddhhmmss or something similar as a suffix, but the (future) users I've talked to so far all said they'd appreciate _N. 

It has to run on Form, right? If it’d be Flow you could use the Job ID. They’re not consecutive per workspace, but they are unique and “simple”

Yes this is running on Form, but there is some debate about moving all of this to Flow. I'll keep this in mind if we ever get there.

In the meanwhile I think I'm opting for ​@nielsgerrits’ approach with a formatted datetime suffix. 

Appreciate the help guys!


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 21, 2025

Could use

  1. PATH Reader to find all  <FGDB Base Name>*.gdb Folders
  2. Tester to filter any of those Folders with today’s yyymmdd
  3. Add a dummy entry with Creator for FGDB Path = <FGDB Base Name>_yyyymmdd_00.gdb in case the Reader+Tester returns nothing (because the first FGDB hasn’t been generated yet for the day)
  4.  Sorter to takes PATH Reader/Tester Features + Dummy Creator Feature and sort FGDB Path by Path, descending order
  5. Sampler to take Top 1 result (the most “recent” run for the day)
  6. String manipulation (StringReplacer with RegEx, or SubStringExtractor->AttributeCreator to remove last 2 chars and add back two new characters incremented by +1 , whatever works)
  7. Join this incremented path+1 to the Features to be Written and using this as your Path Parameter in the Writer

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings