Question

Renaming an input file

  • 5 February 2014
  • 7 replies
  • 25 views

Hi there,

 

 

Slightly odd question that I think I know the anwser to but thought I'd just see if anyone out there has any bright ideas.  We have reader file that undergoes some transformations through a workspace, but what the customer wants to be able to do at the end of the workbench is bascially rename the file based on a new filename that has been generated through the process (but not modify the file in any way).  Is there anyway to do this?  

 

 

I'm guessing not and already using AttributeFileWriter to write the name of the file out to a simple text file where I can wrap the workbench call up in a batch file where I can write some simple code to do the renaming there.  But if anyone can suggest a better way I'd love to hear it!

 

 

Cheers

 

 

Dan

7 replies

Userlevel 5
Hi,

 

 

you can use the fanout option (http://fmepedia.safe.com/articles/How_To/Fanout) on the writer for this.

 

 

David
Hi David,

 

 

Unfortunately these are Point Cloud files of some size (1.5Gb) and the customer simply wants to rename the existing file rather than create a new file, so there is no writer.  I did have a writer that did exactly that but it took around 10 minutes to write and essentially created a copy of the reader file just with a different name.
Userlevel 4
Badge +13
Sometimes a simple DOS command is all that you need.
Indeed although I've already had someone extolling the virtues of Python....
Userlevel 5
Hi,

 

 

it's technically possible to rename the file inside a PythonCaller, but it is probable that it will end in an error if FME is still holding onto the read lock of the input file when the PythonCaller starts.

 

 

A solution could be to concatenate all the rename commands into a DOS batch file that you write out with a Text file writer. You can then call this batch file after the workspace ends.

 

 

David
Userlevel 3
Badge +17
Hi,

 

 

I would use Shutdown Python Script.

 

Save new file path as a global variable with a PythonCaller while processing.

 

In Shutdown Python Script, get the source file path (a parameter value) and the new file path (the global variable), and rename the file.

 

 

Takashi
Badge +21
Use the FILE and DIRECTORY Reader to read the files. Then set the correct parameters within FME and then use the File Copy Writer in MOVE-mode to move the files. No files are read (only filenames) and no files are written (only renamed).

 

 

Reply