Skip to main content
Question

Copying and renaming a folder to a different location


Forum|alt.badge.img

I'm pulling my hair out trying to get filecopy writer to work. What I want to do is copy a folder (and it's sub-folders) to a new location and to rename the copied folder. I'm using user-parameters to prompt for the new folder name but I can't get the file copy to work properly. I've combed through old forums but haven't found anything helpful. I think I can do the renaming with a system caller but I still cant get the filecopy to work... Any help is much appreciated.

 

I feel like this is fairly straight-forward, I'm still quite new to FME.

9 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • June 15, 2020

Hi @mackenziebudda

In the attribute Destination Folder ( transformer AttributeCreator ) , please include:

 

Thanks in Advance,

Danilo

Forum|alt.badge.img

Hey @danilo_fme,

 

It worked! thanks for the help. The only thing now though is that it's not replacing the name of "new project template " with my @value(Project_WO_name). Instead it just creates a new folder with the @value(Project_WO_name) name and the "new project template" folder is nested inside.

 

Any suggestions?


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • June 15, 2020
mackenziebudda wrote:

Hey @danilo_fme,

 

It worked! thanks for the help. The only thing now though is that it's not replacing the name of "new project template " with my @value(Project_WO_name). Instead it just creates a new folder with the @value(Project_WO_name) name and the "new project template" folder is nested inside.

 

Any suggestions?

if you want to change the name of the file, the new name must be stored in an attribute called filecopy_dest_filename.


Forum|alt.badge.img
jdh wrote:

if you want to change the name of the file, the new name must be stored in an attribute called filecopy_dest_filename.

@jdh I thought I'am doing that. I created the attribute called "Project_WO_name". This attribute is then passed to the filecopy writer.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • June 15, 2020
mackenziebudda wrote:

@jdh I thought I'am doing that. I created the attribute called "Project_WO_name". This attribute is then passed to the filecopy writer.

Is filecopy_dest_dataset an absolute or relative path?

 

Is filecopy_source_dataset and individual file, or a folder? Does it contain wildcards?

Forum|alt.badge.img
jdh wrote:

Is filecopy_dest_dataset an absolute or relative path?

 

Is filecopy_source_dataset and individual file, or a folder? Does it contain wildcards?

@jdh

The filecopy_dest_dataset is an absolute path. I have an attribute creator going into the filecopy that sets that attribute as "U:\\2020\\..."

The attribute creator also sets the filecopy_source_dataset as "T:\\2020\\folder_template" where folder_template is a folder with a few empty sub-folders


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • June 15, 2020

If I understand correctly you have something like

 

 

T:\\2020\\folder_template\\subfolder\\etc.

 

 

you want

U:\\2020\\ProjectWO\\subfolder\\etc

 

 

but you are currently getting

 

 

U:\\2020\\ProjectWO\\folder_template\\subfolder\\etc

Forum|alt.badge.img
jdh wrote:

If I understand correctly you have something like

 

 

T:\\2020\\folder_template\\subfolder\\etc.

 

 

you want

U:\\2020\\ProjectWO\\subfolder\\etc

 

 

but you are currently getting

 

 

U:\\2020\\ProjectWO\\folder_template\\subfolder\\etc

@jdh Thats exactly what's happening


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • June 15, 2020
mackenziebudda wrote:

@jdh Thats exactly what's happening

I don't have 2019 on this computer.

 

Can you try creating a fresh workspace with

 

A creator, attributecreator and fileCopy writer.

On the filecopyWriter set the Destination File Copy Folder to C:\\ (or a temp drive, it's irrelevant, but it will be created if it doesn't exist) and then unlink from user parameter.

Create the projectWO user parameter

 

 

The attributeCreator should have the following two attributes

filecopy_source_dataset: T:\\2020\\folder_template

filecopy_dest_dataset: U:\\2020\\$(Project_WO_name)

 

In FME 2020 that produces the correct results.


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