Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: linnoinenHi everyone,
I'm puzzled by Lavastorm's (and BRAINscript's) behaviour when it comes to modifying filenames and renaming them.
What I'm trying to achieve is pretty simple: write a file to a folder, rename it, and add the current date and time to the filename, converting it to .DAT file format.
Looking through the previous posts on moveFile() here, I found a BRAINscript snippet which lets me do almost this -- except when I add the time to the filename, the BRAINscript error says it can't find my file.
My BRAINscript for the Filter node looks like this:
oldFile = "C:\\tmp\\test.csv"
extList = oldFile.split(".")
n = extList.len()
ext = "." + extList[n-1]
dirAndFile = oldFile.replace(ext,"")
newFile = dirAndFile + "_" + date().str() + ".dat"
moveFile(oldFile,newFile)
consume(1,TRUE)
emit newFile
The above code takes the input file, splits off the "csv" and adds the date() as a string, then adds .dat as the extension. Works like a charm.
What alludes me is why doesn't adding and extra "time().str()" to the same line work? For example:
newFile = dirAndFile + "_" + date().str() + "_" + time().str() + ".dat"
If you change the code and run it, the error will be:
Node execution terminated while processing data by error:
error moving file C:\tmp\test.csv: The filename, directory name, or volume label syntax is incorrect.
Also, even trying something like creating separate variables from date and time, and adding them to the filename does not work either.
Super frustrating!
Thanks!
Karri