Skip to main content
Hello

 

I’m new to FME. 

 

How do you rename a source_file  (MapInfo.Tab) and copy it to another folder using a Filecopy writer? I've seen similar questions to this but I still don't know how to do it.

 

I managed to replicate the Filecopy following the instructions here: https://knowledge.safe.com/articles/How_To/Including-files-dynamically-in-a-data-download-result .However, I want to rename my MapInfo tab file (which I am copying with the Filecopy) and I’m not able to do this.

 

This is what my process looks like:

 

 

The source table is named Car_Parking.Tab and I want it to be CARPARKING.Tab  in the output folder. Landmark is copying fine and I don’t need to change the name. These two are part of a bigger workbench which copies many files. 

 

For now Car_Parking.* is copying as Car_Parking.* to my output. I did try various things -changing the _filename_part in an attributecreator, Fanout options (I managed to create a  CARPARKING folder )- Creating a Path and file name reader... etc-  but nothing worked.

 

I saw in some FME community answers " @Value" was added  in the Attributecreater but I couldn't associate @Value to CarParking.

 

Here’s the process for the  CarParking Tab file:
  • Creator: - Creation Instance Attribute: _creation_instance
  • AttributeCreator: AttributeName = source_fileValue = H:\\CoreData\\Places\\Car_Parking.*
  • AttributeFileReader: - Destination Attribute:_file_contents – Source Filename: H:\\CoreData\\Places\\Car_Parking.Tab – source File Character Encoding: Binary (fme-binary)
*I added a AttributeReader in order to be able to modify
  • FilenamePartExtractor: -Source Attribute: source file – Desired Filename Part: Full Filename – Target Attribute: _filename_part
  • AttributeCreator: - AttributeName: destination_file       – Value: $(Path)\\$(Places) -AttributeName:filecopy_source_dataset       –Value:source_file
*I added user parameters with the $(Path) and $(Places) paths
  • Attributecopier:-Source Attribute:Source_file     -Target Attribute:filecopy_source_dataset
-Source Attribute: destination_file   -Target Attribute:filecopy_dest _dataset

 

-Source Attribute: _filename_part   -Target Attribute:filecopy_dest_filename
  • filecopy
Thanks in advance!

 

Dianne
Hi Dianne,

 

 

I would use the Path reader and an AttributeCreator.

 

The reader creates features containing these attributes for each file in the specified folder. You can use them to modify the file name and copy the files with the File Copy writer.

 

-----

 

path_windows: full path of the file

 

path_filename: filename

 

path_rootname: filename without extension

 

path_extension: extension of the file

 

 

To modify the specific filename, an AttributeCreator can be used.

 

Attribute Name: filecopy_dest_filename

 

Value (Conditional Value):

 

If @Valud(path_rootname) = Car_Parking Then CARPARKING.@Value(path_extension)

 

Else @Value(path_filename)

 

 

Then, add the File Copy writer and map the source file path (path_windows) to "filecopy_source_dataset".

 

The data flow and parameter setting of the AttributeCreator looks like this.

 

 

 

Takashi
Hi Dianne,

 

 

I would use the Path reader and an AttributeCreator.

 

The reader creates features containing these attributes for each file in the specified folder. You can use them to modify the file name and copy the files with the File Copy writer.

 

-----

 

path_windows: full path of the file

 

path_filename: filename

 

path_rootname: filename without extension

 

path_extension: extension of the file

 

 

To modify the specific filename, an AttributeCreator can be used.

 

Attribute Name: filecopy_dest_filename

 

Value (Conditional Value):

 

If @Valud(path_rootname) = Car_Parking Then CARPARKING.@Value(path_extension)

 

Else @Value(path_filename)

 

 

Then, add the File Copy writer and map the source file path (path_windows) to "filecopy_source_dataset".

 

The data flow and parameter setting of the AttributeCreator looks like this.

 

 

 

Takashi
Hello Takashi,

 

Thanks so much! It worked.  I truly appreciated the detailed explanation of the AttributeCreator- Value (Conditional Value).

 

Kind regards,

 

Dianne
Hi Dianne,

 

 

I would use the Path reader and an AttributeCreator.

 

The reader creates features containing these attributes for each file in the specified folder. You can use them to modify the file name and copy the files with the File Copy writer.

 

-----

 

path_windows: full path of the file

 

path_filename: filename

 

path_rootname: filename without extension

 

path_extension: extension of the file

 

 

To modify the specific filename, an AttributeCreator can be used.

 

Attribute Name: filecopy_dest_filename

 

Value (Conditional Value):

 

If @Valud(path_rootname) = Car_Parking Then CARPARKING.@Value(path_extension)

 

Else @Value(path_filename)

 

 

Then, add the File Copy writer and map the source file path (path_windows) to "filecopy_source_dataset".

 

The data flow and parameter setting of the AttributeCreator looks like this.

 

 

 

Takashi
Hello Takashi,

 

Thanks so much! It worked.  I truly appreciated the detailed explanation of the AttributeCreator- Value (Conditional Value).

 

Kind regards,

 

Dianne

Hi @Takashi Iijima​ 

Thanks for this solution it worked well for me as well. Could you please help a little more by giving some ideas. I am trying to move some files from one azure storage to another and want to rename those files while moving. In case of file copy transformer it doesn't give option to connect web. I have around thousands of files in Azure Storage. I tried blob connector to upload renamed files with your explained process but not working. Please guide.

Regards


Reply