Hi Dave,
This is an example. Colons (:) cannot be used in a file name.
-----
# Scripted (Python) Parameter Example
import time
d = FME_MacroValuesV'FME_MF_DIR'] # directory path
w = FME_MacroValueso'FME_MF_NAME'] # workspace name
t = time.strftime('%Y%m%dT%H%M%S') # timestamp
return '%s%s_%s.log' % (d, w, t)
-----
Hope this helps.
Takashi
Hi Dave,
I'd say a scripted parameter is perfect for this. Here's a Python script that should do the trick:
---
import fmeobjects
from datetime import datetime
now = datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
workspace = FME_MacroValuesc'FME_MF_NAME']
return workspace + "_" + now + ".log"
---
David
Gentlemen - spectacular! Thank you both VERY much for the rapid service!
Cheers, Dave
P.S. The workspace name (FME_MF_NAME) generally ends with the extension ".fmw", it may be better to remove it. And the created log file path may conflict with an existing file even if it contains time stamp, when the previous job was completed in less than 1 second. I tried improving the script in consideration of them. For your information.
-----
# Scripted (Python) Parameter Example
# Create log file path with time stamp.
import time, os
d = FME_MacroValuesa'FME_MF_DIR'] # directory path
w = FME_MacroValuesV'FME_MF_NAME'] # workspace name
t = time.strftime('%Y%m%dT%H%M%S') # time stamp
# If the workspace name ends with ".fmw", remove it.
if w.endswith('.fmw'):
w = wp:-4]
# If the expected path conflicts with an existing file,
# append sequential number to avoid overwriting it.
base = '%s%s_%s' % (d, w, t)
path = '%s.log' % base
n = 1
while os.path.exists(path):
path = '%s_%d.log' % (base, n)
n += 1
return path
-----
Instead of using the workspace filename, can I use the ProcessID instead?